| Overview | Index | GodLikeMouse JavaScript Framework |
| FRAMES | NO FRAMES |
GLM.DOM.Validator.addCustomField( controlID, errorText, validationFunction, controlType, args )
Method for adding a custom field for validation.
Parameters:
controlID - The control identifier of the input field to validate. This can also be the name for types such as radio.
errorText - The error message to associate with the required field.
validationFunction - The user defined custom validation function.
controlType - (Optional) The control type, default is "text". Valid types are select, text, radio and checkbox.
args - (Optional) Any additional information to be retrieved from the getVioloations method.
Example:
var v = new GLM.DOM.Validator();
function nameValidator(controlToValidate){
if(controlToValidate.value.length > 0)
return true; //passes validation
else
return false; //fails validation
}//end nameValidator()
v.addCustomField("txtFirstName", "First Name is required.", nameValidator);
v.validate(); //validate all required fields.
if(!v.isValid){ //check for failures
var violations = v.getViolations(); //return all failures
var s = "";
for(var i=0; i<violations.length; i++){
s += violations[i].text + "\n";
}
alert(s); //alert all violations
}
| Overview | Index | GodLikeMouse JavaScript Framework |
| FRAMES | NO FRAMES |