|
|
|
Anti-Spam Two Step for Webmasters
If your email address is on a website that's been online for a while you're being blasted with unsolicited email (SPAM). You can delete it or you can eliminate much of it in two simple steps. Step 1: Scramble Your Email Address It isn't human...
Manchester United: Top of the web accessibility league?
A while ago Manchester United launched a separate accessible version of their website, manutd.com/access . There's been lots of publicity surrounding this accessible website and it even picked up an award. This accessible version doesn't offer as...
Microsoft CRM Customization - processing in/out-going email messages
We would like to give you several situations, when you may need custom development and programming to improve Microsoft CRM functionality. This overview is for programmer, software developer, IT specialist, database administrator.
Microsoft...
Search Engine Optimization - Advice and Tactic
Unique content is King. Search engines love new, unique and updated content. If you produce new content at a rate of just one reasonably sized page per day and tied in with the other advice throughout the site, I can almost guarantee you will get...
Search Engine Optimization For Blogs
Copyright © 2004 Priya Shah http://www.priyashah.com Blogging software is really a simple Content Management System (CMS) that easily adds new pages and integrates them into your site's navigational structure and linkage. Blogs and blog posts are...
|
|
| |
|
|
|
|
Validating Numerical Input with JavaScript
What? Make a mistake entering data? Who me? NO WAY! Right.
Every form of data input by a user should be validated in some form or fashion. If you get
clean data in, you won't get garbage out. This tutorial is going to explain how to validate
numerical data entered into a form using JavaScript.
First, let us begin with the code to insert the JavaScript into your HTML document.
Place these lines between the and tags.
This line tells the web browser to expect some JavaScript code and signal the beginning of
the script:
So now the format should look something like this:
My Title
Now on to validating the numerical input.
First we will create a function with one arument:
function validate(mydata){
These lines will test for a blank enty then prompt the user for input:
if (mydata == ""){ alert("Please enter a number.") }
Next we will create a for loop which will look at each character in the data until it
reaches the end:
for(var i=0;i < mydata.length;i++){
Now create a variable and assign the counter variable value to it:
var mydigit = mydata.charAt(i)
To screen out symbols, punctuation, and letters, place an if statement in the loop:
if(mydigit < "0" || mydigit > "9"){
The || in the if statement scans for both conditions.
The next line will alert the user to any mistakes he/she has made:
alert(mydigit + " is not a number.")
Here is the complete code including HTML: ============================================= Numerical Validation
| | | | | | |