I have this code:
$("form").submit(function() {
$(":input").each(function() {
if($(this).val() === "")
alert("Empty Fields!!");
});
});
It works great but when I have more than one form on a page, it checks all forms. I wan't to check only the submitted form using the "this" selector. How shall I implement the "this" selector in my code to check only the submitted form?
I cannot use any id's or classes, only the "this" selector.
requiredattribute and$(this).val()is just more boring way to writethis.value;) As kind of polyfill for required attribute: stackoverflow.com/questions/17479573/…