I am using jQuery Validation Plugin for form validation and I am not able to validate the select box using not the value fields but the text field..
Here my situation:
[HTML]
<form id="form">
<select name="customPrice[0][50]" id="customPrice050">
<option value="2435">Select date... </option>
<option value="474">Friday, Mar 1st</option>
<option value="475">Friday, Mar 8th</option>
<option value="476">Friday, Mar 15th</option>
</select>
<br/>
<input type="submit" value="Click" />
[jQuery]
$(document).ready(function()
{
// add the rule here
$.validator.addMethod("valueNotEquals", function(value, element, arg){
return arg != value;
}, "Value must not equal arg.");
// configure your validation
$("form").validate({
rules: {
"customPrice[0][50]": { valueNotEquals: "2435" }
},
messages: {
"customPrice[0][50]": {
valueNotEquals: "Please select a date!"
}
}
});
}
);
This works very well. The problem is that the value 2435 in not static and it always changes. The only static property is the text "Select date... ". Now I would something like:
"customPrice[0][50]": { textNotEquals: "Select date... " }
Can someone help me?