On 07.07.09 21:09, Robert Poland <email@hidden> wrote:
Hi,
I'm trying to modify a javascript script;
function textBoxOnBlur(elementRef) {
//5754578787, it should be 575-457-8787
var elementValue = elementRef.value;
// Remove all "(", ")", "-", "_", and spaces...
elementValue = elementValue.replace(/\(/g, '');
elementValue = elementValue.replace(/\)/g, '');
elementValue = elementValue.replace(/\-/g, '');
elementValue = elementValue.replace(/\_/g, '');
elementValue = elementValue.replace(/a-z/ig, '')
elementValue = elementValue.replace(/\s+/g, '')
if ( elementValue.length < 10 ) {
alert('The phone number needs 10 characters');
elementRef.select();
elementRef.focus();
return;
}
elementRef.value = (elementValue.substr(0, 3) + '-' +
elementValue.substr(3, 3) + '-' + elementValue.substr(6, 4));
}
What I'm after is for this line to remove all letters;
elementValue = elementValue.replace(/a-z/ig, '')
Not an Answer to your Problem, just an IMHO important sidenote:
If you're coding for a US ONLY Website, this is OK. If the Wbesite's
Auudience is worldwide however, don't be ignorant and force the US
Phone
Format on everyone. Other countries have different formats and
different
length phonenumbers.
Stefan
--
Stefan Seiz <http://www.stefanseiz.com>
Spamto: <email@hidden>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Web-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden