Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Phone Number validation


Message #1 by "Neetu Dhatt" <neetu_dhatt@h...> on Tue, 25 Feb 2003 19:22:38 +0000

Hi everyone
I have a problem validating the phone number.  I want to do 2 main things when validating and IT MUST BE DONE inside
<script></script> tags
<script>
1) Check to see if the values entered are numbers, if not then focus back to the field
2) if they are numbers i want to make sure that the area code is 3 digits long the prefix is 3 digits long and the suffix is 4digits
long.  all 3 of these parts of phone number are entered in different text boxes
generally the phone #'s look like  xxx-xxx-xxxx
</script>
so if anyone can help me, I will really really really appreciate it
Thanks 


 


Tired of spam? Get  advanced junk mail protection with MSN 8.
Message #2 by Mark Eckeard <meckeard2000@y...> on Tue, 25 Feb 2003 12:20:46 -0800 (PST)
Are you using vbscript or javascript???

--- Neetu Dhatt <neetu_dhatt@h...> wrote:
> 
> 
> Hi everyone
> I have a problem validating the phone number.  I
> want to do 2 main things when validating and IT MUST
> BE DONE inside <script></script> tags
> <script>
> 1) Check to see if the values entered are numbers,
> if not then focus back to the field
> 2) if they are numbers i want to make sure that the
> area code is 3 digits long the prefix is 3 digits
> long and the suffix is 4digits long.  all 3 of these
> parts of phone number are entered in different text
> boxes
> generally the phone #'s look like  xxx-xxx-xxxx
> </script>
> so if anyone can help me, I will really really
> really appreciate it
> Thanks 
> 
> 
>  
> 
> 
> Tired of spam? Get  advanced junk mail protection
> with MSN 8.
> 


__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/
Message #3 by Jack_Speranza <jsperanza@g...> on Tue, 25 Feb 2003 15:31:11 -0500
On Tuesday, February 25, 2003 2:23 PM Neetu Dhatt was rumored to say:

> I have a problem validating the phone number.=A0 I want to do 2
> main things when validating and IT MUST BE DONE inside <script>
> </script> tags


Neetu --

	Sounds like you're going to want to use client-side JavaScript
to perform your validation.  I would suggest taking a look at using
the built in regular expression object available in JS.  Once you
gain some familiarity working with them, regular expressions are
extremely fast and flexible in handling all your validation needs.
If you don't want to deal with having to familiarize yourself with
REs and their special syntax, you could certainly just perform a
series of string validation techniques in JS...

HTH,


******************************
Jack Speranza
Gryphon Networks
Automating Privacy Compliance for Business
xxx.xxx.xxxx  x129
www.gryphonnetworks.com


-----Original Message-----
From: Neetu Dhatt [mailto:neetu_dhatt@h...]
Sent: Tuesday, February 25, 2003 2:23 PM
To: ASP Databases
Subject: [asp_databases] Phone Number validation




Hi everyone
I have a problem validating the phone number.=A0 I want to do 2 main 
things
when validating and IT MUST BE DONE inside <script></script> tags
<script>
1) Check to see if the values entered are numbers, if not then focus 
back to
the field
2) if they are numbers i want to make sure that the area code is 3 
digits
long the prefix is 3 digits long and the suffix is 4digits long.=A0 all 
3 of
these parts of phone number are entered in different text boxes
generally the phone #'s look like  xxx-xxx-xxxx
</script>
so if anyone can help me, I will really really really appreciate it
Thanks


=A0


Tired of spam? Get  advanced junk mail protection with MSN 8.

Message #4 by "Drew, Ron" <RDrew@B...> on Tue, 25 Feb 2003 16:29:44 -0500
This may help you...just need to modify it to test for numerics 
etc...cut, paste, try then modify.
<HEAD>
<SCRIPT LANGUAGE=3D"JavaScript">
<!-- Begin
var n;
var p;
var p1;
function ValidatePhone(){
p=3Dp1.value
if(p.length=3D=3D3){
	//d10=3Dp.indexOf('(')
	pp=3Dp;
	d4=3Dp.indexOf('(')
	d5=3Dp.indexOf(')')
	if(d4=3D=3D-1){
		pp=3D"("+pp;
	}
	if(d5=3D=3D-1){
		pp=3Dpp+")";
	}
	//pp=3D"("+pp+")";
	document.frmPhone.txtphone.value=3D"";
	document.frmPhone.txtphone.value=3Dpp;
}
if(p.length>3){
	d1=3Dp.indexOf('(')
	d2=3Dp.indexOf(')')
	if (d2=3D=3D-1){
		l30=3Dp.length;
		p30=3Dp.substring(0,4);
		//alert(p30);
		p30=3Dp30+")"
		p31=3Dp.substring(4,l30);
		pp=3Dp30+p31;
		//alert(p31);
		document.frmPhone.txtphone.value=3D"";
		document.frmPhone.txtphone.value=3Dpp;
	}
	}
if(p.length>5){
	p11=3Dp.substring(d1+1,d2);
	if(p11.length>3){
	p12=3Dp11;
	l12=3Dp12.length;
	l15=3Dp.length
	//l12=3Dl12-3
	p13=3Dp11.substring(0,3);
	p14=3Dp11.substring(3,l12);
	p15=3Dp.substring(d2+1,l15);
	document.frmPhone.txtphone.value=3D"";
	pp=3D"("+p13+")"+p14+p15;
	document.frmPhone.txtphone.value=3Dpp;
	//obj1.value=3D"";
	//obj1.value=3Dpp;
	}
	l16=3Dp.length;
	p16=3Dp.substring(d2+1,l16);
	l17=3Dp16.length;
	if(l17>3&&p16.indexOf('-')=3D=3D-1){
		p17=3Dp.substring(d2+1,d2+4);
		p18=3Dp.substring(d2+4,l16);
		p19=3Dp.substring(0,d2+1);
		//alert(p19);
	pp=3Dp19+p17+"-"+p18;
	document.frmPhone.txtphone.value=3D"";
	document.frmPhone.txtphone.value=3Dpp;
	//obj1.value=3D"";
	//obj1.value=3Dpp;
	}
}
//}
setTimeout(ValidatePhone,100)
}
function getIt(m){
n=3Dm.name;
//p1=3Ddocument.forms[0].elements[n]
p1=3Dm
ValidatePhone()
}
function testphone(obj1){
p=3Dobj1.value
//alert(p)
p=3Dp.replace("(","")
p=3Dp.replace(")","")
p=3Dp.replace("-","")
p=3Dp.replace("-","")
//alert(isNaN(p))
if (isNaN(p)=3D=3Dtrue){
alert("Check phone");
return false;
}
}
//  End -->
</script>
</HEAD>

<BODY>
<div align=3D"center">
<form name=3DfrmPhone>
Enter Telephone Number<br>
(To refresh, hold down shift and press the browser refresh button)<br>
<input type=3Dtext name=3Dtxtphone maxlength=3D"13" 
onclick=3D"javascript:getIt(this)" >
</form></div>

-----Original Message-----
From: Neetu Dhatt [mailto:neetu_dhatt@h...]
Sent: Tuesday, February 25, 2003 2:23 PM
To: ASP Databases
Subject: [asp_databases] Phone Number validation




Hi everyone
I have a problem validating the phone number.=A0 I want to do 2 main 
things when validating and IT MUST BE DONE inside <script></script> tags 
<script>
1) Check to see if the values entered are numbers, if not then focus 
back to the field
2) if they are numbers i want to make sure that the area code is 3 
digits long the prefix is 3 digits long and the suffix is 4digits 
long.=A0 all 3 of these parts of phone number are entered in different 
text boxes generally the phone #'s look like  xxx-xxx-xxxx </script> so 
if anyone can help me, I will really really really appreciate it Thanks


=A0


Tired of spam? Get  advanced junk mail protection with MSN 8.


  Return to Index