Jquery form validation using pre-define class in input type -


i'm trying create function validate form using jquery. have used bootstrap 3 design form , want validate each field(s) mandatory , special validation.

<form method="post>       <div class="form-group">       <label for="customername" class="control-label">customer name</label>       <input type="text" name="customername" class="form-control mandatory">       <p class="help-block text-danger error-mandatory"></p>   </div>   <div class="form-group">      <label for="mobile" class="control-label">mobile no</label>      <input type="text" name="mobile" class="form-control mandatory validate-mobile">       <p class="help-block text-danger error-mandatory error-mobile"></p>   </div>   <div class="form-group">     <label for="email" class="control-label">email</label>     <input type="text" name="email" class="form-control mandatory validate-email">     <p class="help-block text-danger error-mandatory error-email"></p>   </div>   <div class="form-group">     <label for="amount" class="control-label">amount</label>     <input type="text" name="amount" class="form-control mandatory validate-numeric">     <p class="help-block text-danger error-mandatory error-numeric"></p>   </div>   <div class="form-group">   <input type="submit" name="submit" onclick="validateform();" class="btn btn-default">   </div> </form> 

when user click on submit button form validate input type following:

  • if class mandatory - validate empty or not
  • if class mandatory validate-email - validate empty , validate email format
  • if class mandatory validate-mobile - validate empty , numeric 10 digit only
  • if class mandatory validate-numeric - validate empty , accept numeric only

and error message show in

tag class with:

'error-mandatory' , 'error-email', 'error-numeric', 'error-mobile' 

respectively. want create js file can call function in form on submit button. how build solution, example highly appreciated.


Comments

Popular posts from this blog

How to connect android app to App engine -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

php - display validation error message next to the textbox in codeigniter -