Side navigation
#5415 closed feature (fixed)
Opened October 28, 2009 02:11PM UTC
Closed February 05, 2010 08:33PM UTC
validate - getting error messages
Reported by: | ThomasBauer | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 1.4 |
Component: | plugin | Version: | 1.3.2 |
Keywords: | validate | Cc: | |
Blocked by: | Blocking: |
Description
It would be helpfull to egt by the attributes put in HTML (for example: validate="required: true, minlength:50") the responding message. Whith this you can add a help into your dise and user must not wait to get an error to know how to fill the form.
I have now found a solution. I have extended the prototype definitons with the following code:
getMessage: function(element) {
element = this.clean( element );
// if radio/checkbox, validate first element in group instead
if (this.checkable(element)) {
element = this.findByName( element.name )[0];
}
var rules = $(element).rules();
var dependencyMismatch = false;
var listMessages = new Array();
for( method in rules ) {
var rule = { method: method, parameters: rules[method] };
var message = this.defaultMessage( element, rule.method );
if ( typeof message == "function" )
message = message.call(this, rule.parameters, element);
listMessages.push(message);
}
return listMessages;
},