|
|
|
Building websites using web templates
Gone are the days when you had to rely on a web-designer to design your websites. New technologies with innovative ideas have brought out a new variant to this trend in the form of ready to use website templates. So what are web templates? Well,...
HOW TO BUILD A SUCCESSFUL WEB SITE
Think you have a successful site? Maybe you really do, but chances are it might need a little mending. Here's some simple ideas to remember when trying to create a friendly, worthy site. 1. Looks aren't everything. Most sites can be categorized...
How To Design A Web Site
I'm not a professional web site designer and openly admit there is a lot that I don't know. But if you're a beginner I probably know more than you do, so the listen up. Rather than give a lengthy dissertation on web design I have broken it down...
IIS and ASP: Microsoft's Server
Despite Microsoft's dominance of everything to do with
computers, their web server software sits on a relatively low
20% market share, thanks to the popularity of Apache. However,
20% of millions of servers is still a pretty substantial...
Let's Go Back To Photoshop's Beginning
Perhaps you may be wondering how Photoshop started? Or perhaps
you do not care so long as it is there to bring life to images,
photos and texts you will be fine?
Whatever the reason may be, it is still better to look back in
order to move...
|
|
| |
|
|
|
|
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
| | | | | | |