I am using the http://bassistance.de/jquery-plugins/jquery-plugin-validation/ plug in with the follow pseudo block that I need to fix:
jQuery("#SearchForm").validate({
rules: {
Company: "required",
CompanyName: {
regex: "[a-zA-Z]*",
required: true,
minlength: 2
}
},
messages: {
Company: "Type required.",
CompanyName: "Only A-Z Allowed in the name."
},
errorPlacement: function(error, element) {
error.appendTo('#JsErrorMsg');
}
});
basically I have 1 input type text and 1 select, I want to validate that either or can be used, but at least 1 must be used, if the text box is used, it should only accept characters to search on a name field, the other select list is a 1-x list of company ids. I am hoping to build off this plug in, if it exists, before growing my own and using the same styles it uses. it would seem odd if this library can not do this.
thank you for your help, cheers
I am going to toss credit to @zod here but I wanted to post the final js for everyone to see. help others in the community.
jQuery("#SearchForm").validate({
rules: {
MallMgmtCompanyID: {
required: true
},
parent: {
required: function(element) {
if(jQuery("#MallName").length < 3 && jQuery("#MallMgmtCompanyID").val() === ""){
return false;
}
}
}
},
messages: {
MallMgmtCompanyID: "3 Characters or Company Selected are Required."
},
success: function() {
jQuery('#JsErrorMsg').remove();
UpdateSearch();
},
errorPlacement: function(error, element) {
error.appendTo('#JsErrorMsg');
}
});
jQuery("#searchbutton").click(function(){
jQuery("#SearchForm").valid();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With