javascript - jQuery Validation Plugin: same form, different validation submitHandler -


i using single form in 2 different scenarios - create , edit.

i

<?php if($status == 'new')     echo '<button id="btnsubmit" type="submit" class="btn">submit!</button>'; else     echo '<button id="btnedit" type="submit" class="btn">edit!</button>'; ?> 

what want achieve on javascript end validate form , call correct web service according button pressed. using jquery validation plugin found here.

javascript

$('#myform').validate({     submithandler: function(data) {       $.ajax({         url: "service1.php"         ...... other ajax stuff ..........       });     } }  $('#btnsubmit').click(function() {     // call service1.php });  $('#btnedit').click(function() {     // call service2.php }); 

the method validate can single function , can set flag(for example id in edit page) identify edit page or add page. can check flag in submit handler , submit form needs submitted. i'm not familiar php , hope might you.


Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

java.util.scanner - How to read and add only numbers to array from a text file -

iphone - Three second countdown in cocos2d -