JavaScript Source Code 3000: Forms: Clean CAPS
Clean CAPS
Keep users from typing in all caps, but still allow for capital letter strings for things like initials (JPC) or uppercase abbreviations (NASA or WWII). You can easily change the number of capital letters allowed in a row after which the capital letterstring is converted to lowercase.
JavaScript Source Code 3000: Forms: Clean CAPS
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 CLEAN CAPS:
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: Ronnie T. Moore, Editor -->
<!-- Idea by: Zachary McDermott -->
<! >
<! >
<!-- Begin
function cleanCAPS(str) {
capsallowed = 3; // Lowercase if more than ## CAPS in a row
do {
eval("re = /([A-Z]{" + (capsallowed+1) + ",})/g;");
myArray = str.match(re);
if (myArray) {
eval("re = /" + myArray[0] + "/;");
str = str.replace(re, ""+myArray[0].toLowerCase());
}
} while (myArray);
return str;
}
// End -->
</script>
</HEAD>
<!-- STEP TWO: Copy this code into the BODY of your HTML document -->
<BODY>
<center>
<form name=test action="your-script.cgi" onSubmit="this.comments.value=cleanCAPS(this.comments.value); return true;">
<input type=text name=comments value="HELLO THERE, my inITIALS are TJM, and I LOVE the EMP." size=60>
<input type=submit value="Submit">
</form>
</center>
<!-- Script Size: 1.24 KB -->
Wyszukiwarka
Podobne podstrony:
clean coal aSteinberg Clean 3 0Clean A Mindspace Investigatio2008 09 Clean Archivist Creating Backups with TimevaultSteinberg Clean 4 0Alanis Morissette Hands cleanfunction ob end clean2012 05 21 Pol 6 PILN2010112 cleanfunction ob end cleanob end cleanclean usedcleanSteinberg Clean 3 0qmail clean 8green day coming cleanf c acylation clean alternativepligg cleanwięcej podobnych podstron