ketchup-plugin
ketchup-plugin copied to clipboard
Error on select validation
I tried to make a required select (combobox) and got the following error:
b.attr("type") is undefined jQuery.ketchup.validation("required","...tween {arg1} and {arg2}.",function(g, ...
Is possible validation of select elements?
i also tried to use the default "required" validation on a select element. This produces the following error:
Uncaught TypeError: Cannot call method 'toLowerCase' of undefined
which is being generated by this line:
.validation("required","This field is required.",function(g,b,c){g=b.attr("type").toLowerCase();return g=="checkbox"||g=="radio"?b.attr("checked")==true:c.length!=0})
would appear that the required validation will only work on input tags that have an attribute set. textareas and selects will not have an attr and so will be undefined.
$.ketchup.validation('subject', 'You have not selected a subject!', function(form, el, value) { return ( value != 0 ); });
where my select has a zero value default that looks like :
while i'm here i got around a required textarea with another custom validation
$.ketchup.validation('message', 'The message field is too short or empty!', function(form, el, value) { return ( $.trim(value).length > 0 ); }); $('#contact-form').ketchup({}, { '#subject' : 'subject', '#message' : 'message', });