The function below tests/validates a dashed or undashed number field. 
In the example below, it is assumed that the number is either entered with its dashes or without its dashes. 
 
function CheckNo(fldno) { 
	// validates item format of 11-12345-1234 
	var matchArr = itemno.match(/^(\d{2})-?\d{5}-?\d{4}$/);		// tests for dashed formated number string 
	var matchNumArr = itemno.match(/\d{11}/);						// tests for all number string 
	// alert ('match:' + matchArr); 
	if ((itemno.length == 13 && matchArr != null) || (itemno.length == 11 && matchNumArr != null)){ 
		return true; 
	} else { 
		// bad format 
		return false; 
	} 
}
  
previous page
 
  |