when i select a type from a drop down box the form fields are changing .
changing means hiding or showing , so according to the drop-down value the form fields are hiding and showing , i need to add j query validation plugin to this form ,
i have a input
<div class="form-item">
<div class="catergory-inputs">
<input name="address" type="text" class="textarea_medium"
id="Address" value="<?php echo $address['value'] ; ?>" />
</div>
</div>
i validate this
var x=$("#contactinfo").validate({
rules: {
address: {
required: true,
minlength: 3,
maxlength: 50,
lettersonly: true
},
},
messages: {
address: {
required: "Enter your Address",
minlength: "At least 3 characters long"
},
}
});
i want to validate this field if only this field is not hiding . like this
var x=$("#contactinfo").validate({
rules: {
if(not hiding) {
address: {
required: true,
minlength: 3,
maxlength: 50,
lettersonly: true
}
},
},
messages: {
if(not hiding) {
address: {
required: "Enter your Address",
minlength: "At least 3 characters long"
}
},
}
});
how can i do this , i saw similar questions in stack-overflow .but there were no answer to mh question there , plz help me ……………………….. 🙁
I wanted to conditionally validate a username field to make sure it was not in the database but only on creating a new user. So when creating a new I placed a javascript variable
var newUser=true;else editing existing uservar newUser=false;Then in my rules portion of my validate I put
required: (newUser)?true:falseThis causes validate to validate the username field only if new user is
true. If we loaded up an existing user, then therequiredportion of the rule will have the valuefalsesimply by adding the javascript var in your PHP code.Remember, you can put javascript into a json object. Because it’s all javascript!
These are the resources I used in learning about validate: http://www.ferdychristant.com/blog//articles/DOMM-7LZJN7 //article detailing how to really use validate. http://www.ferdychristant.com/blog//pages/jQuery%20validation%20code
http://randomactsofcoding.blogspot.com/2008/10/starting-with-jquery-how-to-write.html
http://docs.jquery.com/Plugins/Validation/Methods/required#dependency-expression
There is also an amazing depth of information simply in http://docs.jquery.com/Plugins/Validation …you just gotta click through it all!