| Overview | Index | GodLikeMouse JavaScript Framework |
| FRAMES | NO FRAMES |
GLM.DOM.Validator.addRequiredField( controlID, errorText, controlType, args )
Method for adding a required 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.
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();
v.addRequiredField("txtFirstName", "First Name is required.");
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 |