javascript - clearing a input field if it is invalid -


i using validation plugin. trying figure out how clear text field, if field invalid .

my javascript code follows

$(document).ready(function() { $("#enrollform").validate({     rules: {         email: {             required: true,             email: true         },         vemail: {             required: true,             email: true,             equalto: "#email"         },         offer_code: {             required: false,             remote: "check_code.php"         }     } });}); 

i trying clear out field called offer_code if field invalid. possible in validate function?

alex

check out:

http://docs.jquery.com/plugins/validation/valid

the example:

$(document).ready(function() { $("#enrollform").validate({     rules: {         email: {             required: true,             email: true         },         vemail: {             required: true,             email: true,             equalto: "#email"         },         offer_code: {             required: false,             remote: "check_code.php"         }     } });});  $("#enrollform").blur(function() {   if($("#enrollform").valid()) {     //success code?   } else {     $("#enrollform").val('')   } }); 

Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -