JavaScript
By Eric Korson
Code:
<script type="text/javascript"> <!-- function alpha(e) { var k; document.all ? k = e.keyCode : k = e.which; return ((k > 64 && k < 91) || (k > 96 && k < 123) || k == 8); } // --> </script> <form id="example" action="javascript://"> Letters Only <input type="text" onkeypress="return alpha(event)" /> </form>
Allow Letters Only
(Try to type in something else but letters)
Code:
<script language="javascript" type="text/javascript"> function allowAlphaNumericOnly(field) { var valo = new String(); var which =".0123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM "; //needs the space to allow the space var chars = field.value.split(""); for (i = 0; i < chars.length; i++) { if (which.indexOf(chars[i]) != -1) valo += chars[i]; } if (field.value != valo) field.value = valo; } </script> <form> Allow Custom Letters Numbers Only <input name="text" type="text" id="text" size="20" onkeyup="allowAlphaNumericOnly(this)"> <input type="reset" value="Reset"> </form>
Allow Letters & Numbers Only
Code:
<form name="confirmDelete"> <select id="image_edit" name="image_edit" style="background-color:##EBEBEB;"> <option value="1" selected>Editing Picture 1 </option> <option value="2">Editing Picture 2 </option> <option value="3">Editing Picture 3 </option> <option value="4">Editing Picture 4 </option> </select> <input type="submit" value="Delete confimation of selection" name="delete" onClick="return confirm('Are you sure you want to delete image ' + document.confirmDelete.image_edit.value +'? ')" /> <input type="submit" value="Delete Confimation" name="delete" onClick="return confirm('Are you sure you want to delete this file? ')" /> </form>
Confirm Delete without leaving the submit input tag
Editing Picture 1
Editing Picture 2
Editing Picture 3
Editing Picture 4
Code:
<script language="javascript" type="text/javascript"> function count(field,maxchar) { if (field.value.length > maxchar) { field.value = field.value.substring(0, maxchar); } } </script> <form name="Form1"> Enter text (max 128 characters):<br> <textarea name="txt1" cols="50" rows="3" onkeyup="count(document.Form1.txt1,128); document.getElementById('cnt1').innerHTML=(128 - this.value.length);"></textarea> <span id="cnt1">128</span> left<br><br> Enter text (max 256 characters):<br> <textarea name="txt2" cols="50" rows="6" onkeyup="count(document.Form1.txt2,256); document.getElementById('cnt2').innerHTML=(256 - this.value.length);"></textarea> <span id="cnt2">256</span> left<br><br> </form>
Text Area Counter
Enter text (max 128 characters):
128
left
Enter text (max 256 characters):
256
left