codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  need help with validation  arasaki1 at 15:58 on Thursday, April 29, 2004
 

I have created a web form using asp. The form needs the user to input a number and only a number in the input fields. How would be the best way to validate that? I am not good with Javascript so i am open to any and all suggestions.

Thank you

  Re: need help with validation  cherni99 at 17:47 on Wednesday, May 12, 2004
 

It all depends on whether you want to validate it client-side or server side. Client side saves time etc.

here is some code you could use...
<!--------------------------------------------------------------------
<html>
<title> blank page </title>
<head>
<style type="text/css">
body { font-family:verdana; font-size:8pt; text-decoration:none}
</style>
<script type="text/javascript" language="javascript">
function verifyField(string, daMode) {
if (!string.value) return false;
if(daMode == "digit") var iChars = "0123456789./";

newValue = ""

for (var i = 0; i < string.value.length; i++) {
if (iChars.indexOf(string.value.charAt(i)) != -1)
{
newValue += string.value.charAt(i)
}
}
string.value = newValue
return true;
}
</script>
</head>
<body bgcolor="#FFFFFF" topmargin="0" leftmargin="0">
<form name="form_name">
<table cellpadding=0 cellspacing=5 border=0>
<tr>
<td align="left">Your Number:</td><td align="left"><input type="text" name="dob" onKeyUp="verifyField(this,'digit')"></td>
</tr>
<tr>
<td><input type="submit" value="Submit"></td>
</tr></table>
</form>

</body>
</html>
---------------------------------------------------------------------------->

what it does is it detects a non-digit and removes it.

Hope this helps ;-)

  Re: need help with validation  arasaki1 at 18:59 on Wednesday, May 12, 2004
 

Thank You, I do believe this will help me.

  Re: need help with validation  cherni99 at 09:40 on Thursday, May 13, 2004
 

No worries!








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Re: Print and print preview file on the website without using the File - Print on the IE
•  Re: ASP.NET web controls
•  Re: JavaSript Problem In Mac Safari Browser
•  Re: DHTML div positionning Problem
•  Convert script to NS6 compatible - Please Help!
•  Print .doc file from the website using System.Diagnostics.Process
•  Re: Fullscreen code
•  Re: iframe targeting
•  Excel n ASP


Recent Articles
Communicating with the Database (Using ADO)
MagicGrid
Simple Thumbnail Browsing Solution
Type Anywhere
A Better Moustrap: FmtDate to replace FormatDateTime
ASP.NET Forum Source Code
Internal Search Engine
Javascript Growing Window
Simple date validation
Search engine friendly URLs using ASP.NET (C#.NET)


Site Survey
Help us serve you better. Take a five minute survey. Click here!

© Copyright codetoad.com 2001-2005