Continued from page 1
reaches
end:
for(var i=0;i < mydata.length;i++){
Now create a variable and assign
counter variable value to it:
var mydigit = mydata.charAt(i)
To screen out symbols, punctuation, and letters, place an if statement in
loop:
if(mydigit < "0" || mydigit > "9"){
The || in
if statement scans for both conditions.
The next line will alert
user to any mistakes he/she has made:
alert(mydigit + " is not a number.")
Here is
complete code including HTML: =============================================
Numerical Validation