Subject: RE: Validate phone number.
OK, this will probably work:
In the JS Header, add the following code:
//=======================================
var fieldvalues = new Array();
var thisForm;
function validateNumber(fld, maxNumber, nextFld) {
var onlyNumbers = fld.value.replace(/([^0-9])/g, '');
fld.value = onlyNumbers;
var match = /([0-9]+)/i.exec(fld.value);
if(match[1].length == maxNumber) {
nextFld.focus()
}
}
//=======================================
Then, for each field h1, h2 , and h3, add the following code:
For h1:
//=======================================
onBlur:
validateNumber(this, 3, thisForm.h2);
onChange:
validateNumber(this, 3, thisForm.h2);
onFocus:
fieldvalues[this.name] = this.value;
onKeyUp:
validateNumber(this, 3, thisForm.h2);
//=======================================
For h2:
//=======================================
onBlur:
validateNumber(this, 3, thisForm.h3);
onChange:
validateNumber(this, 3, thisForm.h3);
onFocus:
fieldvalues[this.name] = this.value;
onKeyUp:
validateNumber(this, 3, thisForm.h3);
//=======================================
For h3:
//=======================================
onBlur:
validateNumber(this, 4, thisForm.h1);
onChange:
validateNumber(this, 4, thisForm.h1);
onFocus:
fieldvalues[this.name] = this.value;
onKeyUp:
validateNumber(this, 4, thisForm.h1);
//=======================================
Note that for h3, rather than cycling back to h1 on successful validation, change
thisForm.h1
to
thisForm.NextTargetField