JavaScript Source Code 3000: Forms: Validation (Num. or Chars)
Validation (Num. or Chars)
Validates an input field to make sure that only a number or character is entered. If you enter a number or a letter everything you can continue on. But, try entering another value like an exclamation point (!), an ampersand (&), or a dollar sign ($) and see what happens. It even highlights the incorrect entry field for you. Nice!
JavaScript Source Code 3000: Forms: Validation (Num. or Chars)
Simply click inside the window below, use your cursor to highlight the script, and copy (type Control-c or Apple-c) the script into a new file in your text editor (such as Note Pad or Simple Text) and save (Control-s or Apple-s). The script is yours!!!
<!-- TWO STEPS TO INSTALL VALIDATION (NUM. OR CHARS):
1. Copy the coding into the HEAD of your HTML document
2. Add the last code into the BODY of your HTML document -->
<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<! >
<! >
<!-- Begin
function validate(field) {
var valid = "abcdefghijklmnopqrstuvwxyz0123456789"
var ok = "yes";
var temp;
for (var i=0; i<field.value.length; i++) {
temp = "" + field.value.substring(i, i+1);
if (valid.indexOf(temp) == "-1") ok = "no";
}
if (ok == "no") {
alert("Invalid entry! Only characters and numbers are accepted!");
field.focus();
field.select();
}
}
// End -->
</script>
</HEAD>
<!-- STEP TWO: Copy this code into the BODY of your HTML document -->
<BODY>
<center>
<form onSubmit="http://your-web-site-address-here.com/script.cgi">
<input type=text name="entry" onBlur="validate(this)">
<br>
<input type=submit value="Submit Form">
</form>
</center>
<!-- Script Size: 1.13 KB -->
Wyszukiwarka
Podobne podstrony:
val charcałkowanie num metoda trapezów3E D&D Adventure 06 or 08 EquinoxCipriani Invisible Relligion or Diffused Religion in Italychar spd40char wfs130npush or fold heads upOr Operator koparko spycharkiwybrane char pierwchar nua25hcbComing Closer or Drifting ApartOr Kasjer na stacji paliwfunction msql num rowswięcej podobnych podstron