[an error occurred while processing this directive]

Home

dating Directory


More
dating Articles

WRITERS WANTED! (click-me)

Feature Article:

Personals - Do's and Dont's For Women Dating
Woman's Touch: Dating Do's and Dont's For Females It can be difficult to be a woman in the dating arena. A lot of things can go wrong for you more than it can for your male counterpart. Plus, men can be really dense about a few...

Six Things Every Single Christian Should Know Before Dating Online (Part One)
Years ago, online dating had a reputation that was less than desirable. But today, that stigma is quickly passing. Thousands of single Christians are currently finding friends and establishing relationships through online dating. Major websites like...

[an error occurred while processing this directive]

Validating Numerical Input with JavaScript

[an error occurred while processing this directive]       Navigation

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




Guess a number between 1 and 1000:





=============================================

You can test the above code by copying and pasting it into a text document then view it in

your browser.

And that's how easy it is to test user input for numerical input.

About the Author

(c)2004 BiosBrain
David Morse is the owner of http://www.biosbrain.com which is a full service support site featuring articles on programming, graphics, web-based business and more! Come visit us today!

[an error occurred while processing this directive]

More Reading:


Successful Dating and Marriage 1

Midlife Dating Filling Your Social Calendar

Singles Dating Meeting Women

Personals The Ins and Outs Of Online Dating

Dating with Confidence

 
Dating Communication Dos Donts

Why Online Dating is so Tough For Men

Dating Advice Never Stop Dating

I Found Love at a Online Dating Site

8 Minute Dating For singles with no time for small talk

dating Home

dating Directory

Additional Reading


The Risks Of Online Dating
There is no question that the popularity of online dating has revolutionized the way potential couples meet each other. These days, it is not uncommon for the average single person to participate in an online dating service. In fact, this trend...

Black Dating Online
Black Dating Online Young, black professionals can meet other attractive, successful singles through Professionalsingles.com. So many dating sites develop their focus around ethnicity or religion. There are black dating sites, Jewish dating...

The Pro's Of Online Dating
Dating, these days, is far different from how it was back then. People usually met at a party or were hooked up by friends then in time, the couple would realize whether the friendship could go on to the next level or it was never meant to...



 

 

Internet Search for: code, validating, dating

[an error occurred while processing this directive]

[an error occurred while processing this directive]

 

Copyright   [an error occurred while processing this directive]