0

I have written jQuery like below

          $("#form-search").submit(function(e){
                       e.preventDefault();
                           if (validateForm() === true) {   
                              $('#studentmodal').modal('show');
                              //alert('the form is valid');
                            }
                     return false;
           });

Now I want to display pop up only if form has been validated successfully. The above code is not working!!!

Please help !!!

Nida
  • 1,672
  • 3
  • 35
  • 68

2 Answers2

1

your validateform() function is not defined means that function not exist. are you using library for validation if not then you will have to define validation function. follow these two links for validate function.

A simple jQuery form validation script

https://www.w3schools.com/js/js_validation.asp

Community
  • 1
  • 1
Naveen Giri
  • 535
  • 6
  • 17
1

You can call the valid() method of jquery validation. Like

$('#form').submit(function(evt) {

evt.preventDefault();

.....

if( $('#form').valid() ) {
   //submit the form via ajax
} else {
   //show errors
}

});

});