![]() |
problem with checking a value within in a form is a number in a set range
Trying to write a script that will check the value in the form is a number between the range of 1 to 99999.
1) The script work mostly except for two things if you put a number then letter it won’t detect that you entered letters as well as numbers 2) I want it to run the script on onblur event, however every time I try the script does not work at all. Did study java years and year ago and found I forgotten most things if people can point out where I am going wrong would be very greatful Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">Damien |
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
javascript has changed a lot over the years. Maybe this site might help you http://www.quirksmode.org/js/contents.html or look at http://www.w3schools.com/js/js_examples.asp
For a slightly different way for doing your problem (and I spent some time on it so want some one to look at it LOL) Here is my take: Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
I haven't tested it but
else if((num <= 99999) || (num >= 1)) { should be else if((num <= 99999) && (num >= 1)) { although I prefer to write it Code:
else if((num >= 1) && (num <= 99999)) { |
@Damien001
If you see code like this Code:
<script language="JavaScript1.2">Code:
<script type="text/javascript">Valuable document: Code Conventions |
| All times are GMT +1. The time now is 10:12 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.