Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 19th, 2004, 01:51 AM
Authorized User
 
Join Date: Jan 2004
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
 
Old April 19th, 2004, 03:30 AM
Friend of Wrox
 
Join Date: Jun 2003
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.
======================================
 
Old April 19th, 2004, 03:51 AM
Authorized User
 
Join Date: Jun 2003
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
 
Old April 19th, 2004, 11:20 PM
Authorized User
 
Join Date: Jan 2004
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the sol!

 
Old April 19th, 2004, 11:36 PM
Authorized User
 
Join Date: Jan 2004
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

 
Old April 20th, 2004, 12:50 PM
Authorized User
 
Join Date: Jun 2003
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
 
Old April 21st, 2004, 06:06 AM
Authorized User
 
Join Date: Jan 2004
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks for the code!
 
Old April 21st, 2004, 06:07 AM
Authorized User
 
Join Date: Jan 2004
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks for the code!

regards
ashu





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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.