and I want it to validate that the phone number is that way:
bb-ccc-cccc
This is what I got so far and I can't get it done:
<script type="text/javascript">
String.prototype.isPhoneNumber = function()
{
return /([1-9]\d{2})\s?\d{3}-\d{4}$/.test(this);
}
function checkPhoneNumber()
{
var f = document.forms[0];
alert('Valid phone number: ' + f.elements[0].value.isPhoneNumber());
return false;
}
</script>
<form action="#" onSubmit="return checkPhoneNumber();">
<input type="text" id="number">
<input type="submit" value="Submit">
Thanks