Take a look at js/prototype/validation.js
.....
onSubmit : function(ev){
if(!this.validate()) Event.stop(ev);
},
validate : function() {
var result = false;
var useTitles = this.options.useTitles;
var callback = this.options.onElementValidate;
...
Then take a look at js/mage/adminhtml/form.js or (/js/varien/form.js)
varienForm.prototype = {
initialize : function(formId, validationUrl){
this.formId = formId;
this.validationUrl = validationUrl;
this.submitUrl = false;
if($(this.formId)){
this.validator = new Validation(this.formId, {onElementValidate : this.checkErrors.bind(this)});
}
this.errorSections = $H({});
},
then
var loginForm = new VarienForm('loginForm', false);
validator
is a variable (see this.validator = new Validation..)
that store the validation instance.
function onepageLogin(button)
{
//check to see if the validator instance exist and programmatically validate the form
if(loginForm.validator && loginForm.validator.validate()){
//disable the button to prevent multiple click
button.disabled = true;
//submit the form since all the required field are entered
loginForm.submit();
}
}
See Invoke validation