I would like to know how I can validate the input value that comes from a Datalist. I mean, if I have a Datalist where the user can start to write
Datalist
Try this:
And on form submit you can check:
var val = $("#txt").val(); var obj = $("#colours").find("option[value='" + val + "']"); if(obj != null && obj.length > 0) alert("valid"); // allow form submission else alert("invalid"); // don't allow form submission