I’ve got working validate function for my input fields :
$.tools.validator.fn("#password", function(input, value) {
return value!='Password' ? true : {
en: "Please complete this mandatory field"
};
});
$("#form").validator({
position: 'bottom left',
messageClass:'form-error',
message: '<div><em/></div>' // em element is the arrow
});
My input field :
<input type="password" id="password" class="full" value="" name="j_password" required="required" placeholder="Password" />
And tried the same logic for select but it’s not working :
$.tools.validator.fn("#environment", function(select, value) {
return value!='Select Environment' ? true : {
en: "Please choose the environment"
};
});
My select (not working):
<select id="environment" style="opacity: 0; "><option value="Select Environment">Select Environment</option><option value="1">Dev</option><option value="2">Test</option></select>
My select (not working as well ):
<select id="environment" style="opacity: 0; "><option>Select Environment</option><option>Dev</option><option>Test</option></select>
Can someone point out where I’m making mistake and how to fix it ?
Update:
I’m using http://jquerytools.org/documentation/validator/index.html
Solved it, well actually I didn’t I found solution here :
https://gist.github.com/1810536
With following code :