carlosasin
8/21/2013 - 7:49 AM

JS - Check correct Phone using pattern

JS - Check correct Phone using pattern

// Check if phone is correct (accept + - ( ) 123456789)
// @input str string to check
// @return bool
function check_phone(str) {
	var phn = /^([+]*[0-9]*[-]*[(]*[)]*\s*)*$/; 
	if (str != undefined && str.match(phn)) return true;
 	else return false;
}