How to check if form elements are not empty?

You can see if any are empty like this:

$(":input").each(function() {
   if($(this).val() === "")
    alert("Empty Fields!!");
});

You can read on the :input selector here

for a more specific answer, if you only want those types, change the selector like this:

$(":text, :file, :checkbox, select, textarea").each(function() {
   if($(this).val() === "")
    alert("Empty Fields!!");
});

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)