JavaScript Source Code 3000: Forms: Validation (Character)
Validation (Character)
Automatically removes specified characters from input box. Good for fields that require only text/number inputs. Easily modified to accept only text or only numerals.
(Try entering characters other than A-Z and 0 - 9.)
JavaScript Source Code 3000: Forms: Validation (Character)
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 Command-s). The script is yours!!!
<!-- TWO STEPS TO INSTALL VALIDATION (CHARACTER):
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">
<!-- Original: Mikhail Esteves (miks80@yahoo.com) -->
<!-- Web Site: http://www.freebox.com/jackol -->
<! >
<! >
<!-- Begin
var mikExp = /[$\\@\\\#%\^\&\*\(\)\[\]\+\_\{\}\`\~\=\|]/;
function dodacheck(val) {
var strPass = val.value;
var strLength = strPass.length;
var lchar = val.value.charAt((strLength) - 1);
if(lchar.search(mikExp) != -1) {
var tst = val.value.substring(0, (strLength) - 1);
val.value = tst;
}
}
function doanothercheck(form) {
if(form.value.length < 1) {
alert("Please enter something.");
return false;
}
if(form.value.search(mikExp) == -1) {
alert("Correct Input");
return false;
}
else {
alert("Sorry, but the following characters\n\r\n\r@ $ % ^ & * # ( ) [ ] \\ { + } ` ~ = | \n\r\n\rare not allowed!\n");
form.select();
form.focus();
return false;
}
alert("Correct Input");
return false;
}
// End -->
</script>
</HEAD>
<!-- STEP TWO: Copy this code into the BODY of your HTML document -->
<BODY>
<form name=xyz onSubmit="return doanothercheck(this.txtTerm);">
<input type="text" name="txtTerm" size="35" maxlength="50" value="" onKeyUp="javascript:dodacheck(xyz.txtTerm);">
<br>
<input type=submit value=Check>
</form>
<!-- Script Size: 1.72 KB -->
Wyszukiwarka
Podobne podstrony:
val num or charchar spd40char wfs130nwybrane char pierwchar nua25hcbfunction ifx update chardzieci niepelnosprawne charchar?mot400twinEuro Char Supportchar uta112nchar tfc125charchar?mot200więcej podobnych podstron