Pages

Sunday, March 30, 2014

How to create callback function in jQuery's Validate function - techcodesolution
















Today I am going to talk about jQuery's callback function & how we can define in validate function .
 It is very useful when you want to execute another block of code after completion of execution of other function. Suppose you want to change the size of the text before hide the text. You can easily do this with this callback function. Let's take this example :-














In this example we use callback function to hide "p" element. But when we trying to use this callback function
inside validate function it doesn't work. Suppose you want to execute another block of code after check form validation. In this situation you can't use simply callback function. So , to do this task you have to use special keyword "submitHandler". Let's do this with another example :-

Step 1: Create HTML form















Step 2: Define jQuery data validation rules

 








Step 3: Define callback function


Step 4: Output

Here in this example I used alert box just for an example you can  use any jQuery code what do you want to use like ajax code to submit form.

Thanks for visit my blog.

No comments:

Post a Comment