Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: javascript - wildcards
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: javascript - wildcards



Thanks Stefan,

Not only is this a US website it's only a short time local site.


On Jul 8, 2009, at 9:47 AM, Stefan Seiz wrote:

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


Bob Poland - Fort Collins, CO



_______________________________________________
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


References: 
 >Re: javascript - wildcards (From: Stefan Seiz <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.