This validation ensures that the value specified for the
Witness Phone field is in a valid format.
Procedure
In the Witness Information pane, click the
Witness Phone field.
Click the
Validations tab on the control’s
Properties view.
Click the
Add New Validation button.
The
Define Validation dialog opens.
In the
Name field type the following:
phone_number_syntax
Select the
On Value Change radio button.
Type the following JavaScript code in the
Script text area:
//Retrieve the phone value
var phone = this.getValue();
if(phone != null && phone != ""){
//verify it is in the format 888-888-8888
var strippedPhone = '';
var strippedPhone = '';
for(var i=0; i<phone.length; i++){
var c = phone.charAt(i);
var isNonDigitChar = isNaN(parseInt(c));
if(!isNonDigitChar){ // check if c is a digit
strippedPhone += c;
}
}
strippedPhone.length == 10;
} else{
true;
}