JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 16th, 2001, 10:00 AM
Tom Beidler Tom Beidler is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2001
Location: Santa Barbara, CA, USA
Posts: 11 Tom Beidler User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to Tom Beidler
combine 3 fields with javascript

I'm new to javascript and was hoping someone could help me with this issue. Couldn't find existing code.

I have a simple form that requires the end user to submit their phone number. I would like to have 3 fields, area code, 3 digits and then final 4 digits in their own field. I would then like to combine the numbers into one variable before after submitting and before passing the action.

Reply With Quote
  #2  
Old August 16th, 2001, 01:53 PM
DC Dalton DC Dalton is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Location: NE Pa.
Posts: 96 DC Dalton User rank is Private First Class (20 - 50 Reputation Level)DC Dalton User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 h 29 m 32 sec
Reputation Power: 12
Question why go thru all that headache?

Why go thru the headache of three boxes & then adding them together into one field when you can do 1 input box, check it with a regular expression & then send in the one field? Sounds a lot easier huh?

Make a text box lets say called phoneNum & then check it like this with javascript:

function phoneTest() {
with document.forms[0] {

var pattern2 = /\d{3}\-\d{3}\-\d{4}/

if (!pattern2.test(phoneNum.value) {
alert("The phone number you entered is not in the proper format");
phoneNum.focus();
return false();
}
}
}

Of course dont be a jerk when setting up the input box, show them the format they are supposed to enter next to the input box.

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > combine 3 fields with javascript

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap