ketchup-plugin icon indicating copy to clipboard operation
ketchup-plugin copied to clipboard

Error on select validation

Open wbotelhos opened this issue 13 years ago • 2 comments

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?

wbotelhos avatar May 11 '11 11:05 wbotelhos

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.

helgatheviking avatar Jan 29 '12 07:01 helgatheviking

$.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',
});

helgatheviking avatar Jan 29 '12 08:01 helgatheviking