0
votes

I have done jquery validation which is working fine. But I want the error message only first empty field of the form not all the empty fields. Is there any way to exit in rule or message,if some field validation occur. No need to display all error message at time.

1
post your code what you tried . - Pawan Lakhara

1 Answers

2
votes

Check below code you have to use 'return false' when first filed is empty then message will be show and break .try this

 $(document).ready(function () {
    $('#btnSave').click(function () {
           if ($("#txtName").val()== "") {
                   alert("Please Select Name");
                    return false;
            }
           if ($("#txtdep").val()== "") {
                   alert("Please Select department");
               return false;
           }
     });
});