Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 19th, 2004, 01:51 AM
Authorized User
 
Join Date: Jan 2004
Location: , , .
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default Validations through ASP

My ASP Page has a text box[labelled Telephone Number] in which i want that the user should be able to enter ONLY Numeric values. At present any values[text or Numberic] are being entered.
Here is the TextBox:

<td><b>Officer Telephone Number<b></td>
<td><input type="text" id=txtOfficerTelNumber name=txtOfficerTelNumber size = 10 maxlength = 15 value =<%=null%> ></td>

What should i do?

Please help!

Thanks
Ashu
Reply With Quote
  #2 (permalink)  
Old April 19th, 2004, 03:30 AM
Friend of Wrox
Points: 2,376, Level: 20
Points: 2,376, Level: 20 Points: 2,376, Level: 20 Points: 2,376, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , Australia.
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

You might like to read up a bit o regular expressions.
I have not done a lot of this but found this article a good explanation.
http://www.4guysfromrolla.com/webtech/090199-1.shtml

It is in two parts, the second gives an example of this based on phone numbers so you're in luck.


======================================
They say, best men are moulded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
Reply With Quote
  #3 (permalink)  
Old April 19th, 2004, 03:51 AM
Authorized User
 
Join Date: Jun 2003
Location: Rottum, , Netherlands.
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Default

On the server you could use
IsNumeric(variable)
This function retuens a Boolean variable
For the convenience of the user you can use the javascript method isNan(variable), mind that this one returns true if the variable is Not a Number

Regards,

Gerhard Wentink

Gerhard Wentink
Reply With Quote
  #4 (permalink)  
Old April 19th, 2004, 11:20 PM
Authorized User
 
Join Date: Jan 2004
Location: , , .
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the sol!

Reply With Quote
  #5 (permalink)  
Old April 19th, 2004, 11:36 PM
Authorized User
 
Join Date: Jan 2004
Location: , , .
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Dear Gerhard

can you send me a code sample showing how to call this function isNaN()? I mean when should i call it and from where?

thanks
ashu

Reply With Quote
  #6 (permalink)  
Old April 20th, 2004, 12:50 PM
Authorized User
 
Join Date: Jun 2003
Location: Rottum, , Netherlands.
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Given a form with a textbox named "invoiceNumber".
You can call the function below in the onsubmit-event: onsubmit="return validate()"

function validate(){
    if (isNaN(document.forms[0].invoiceNumber.value))
    {
        alert('An invoice number only contains numbers');
        document.forms[0].invoiceNumber.focus();
        return (false);
}

Regards,

Gerhard Wentink
Reply With Quote
  #7 (permalink)  
Old April 21st, 2004, 06:06 AM
Authorized User
 
Join Date: Jan 2004
Location: , , .
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks for the code!
Reply With Quote
  #8 (permalink)  
Old April 21st, 2004, 06:07 AM
Authorized User
 
Join Date: Jan 2004
Location: , , .
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks for the code!

regards
ashu
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Validations in dataGrid p2pMember ASP.NET 1.0 and 1.1 Basics 1 December 7th, 2005 08:17 PM
problem with validations ashokparchuri General .NET 1 April 14th, 2005 08:20 AM
Validations... Flunders Beginning VB 6 3 September 29th, 2004 07:09 AM
Validations not working Ajay Jain ASP.NET 1.0 and 1.1 Basics 1 February 24th, 2004 01:16 PM



All times are GMT -4. The time now is 11:41 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.