Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"[URL unfurl="true"]http://www.w3.org/TR/html4/loose.dtd">[/URL]
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Form Test</title>
<SCRIPT type="text/javascript">
function checkvalue(fldname)
{ //Set a maximum length for string
var maxlen = 5;
if (fldname.value.length > maxlen)
{ //If value is greater than maximum length trim it.
fldname.value = fldname.value.substring(0,maxlen);
}
//Test to make sure string contains only capital letters.
if (!alpha_only(fldname.value))
{
alert("Invalid character");
}
}
function alpha_only(value)
{ //Only allows capital letters. No numbers or symbols.
var re = /^[A-Z]*$/;
return re.test(value);
}
</SCRIPT>
</head>
<body>
<input type="text" name="myText" id="myText" onkeyup="checkvalue(this);">
</body>
</html>
Stamp out, eliminate and abolish redundancy!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<html>
<head>
<SCRIPT type="text/JavaScript">
<!--
var whichfld='';
function keycheck(e,which)
{
var nav4 = window.Event ? true : false;
whichfld=which;
var failed=false;
if (nav4) // Navigator 4.0x
var whichCode = e.which
else // Internet Explorer 4.0x
if (e.type == "keydown") // the user entered a character
var whichCode = e.keyCode
else
var whichCode = e.button;
if (whichCode == 17)
{
document.getElementById(which).blur();
failed=true;
}
if (failed)
return false;
return true;
}
// -->
</SCRIPT>
</head>
<body>
<FORM NAME="keys">
<input type="text" id="myText" onKeyDown="return keycheck(event,this.id);">
</FORM>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Trap Keypress events and block unwanted characters</title>
<SCRIPT type="text/JavaScript">
<!--
var failed;
var lastval='';
function keytest(e)
{
failed=false;
whichfld=window.event.srcElement.id; //Get object of element being tested
lastval=document.getElementById(whichfld).value; //Set global variable to current value of field.
var character = String.fromCharCode(event.keyCode); //Convert keyCode value to ascii character.
for (var x=1;x<arguments.length;x++)
{ //Loop through arguments passed to function and execute each testing function.
var func=arguments[x];
var status=func(character);
if (!status)
failed=true; //Set failed flag so keypress event is canceled and character not written.
}
if (failed)
event.returnValue = false;
}
function followup(which)
{ //If client used a Ctrl-V to pass info into field this will strip anything pasted in.
var curval = document.getElementById(which).value;
if (curval.length > lastval.length+1)
document.getElementById(which).value = lastval;
lastval=document.getElementById(which).value;
}
function AZ(value) //Only allow capital letters. No numbers or symbols.
{ //Only allows capital letters. No numbers or symbols.
var re = /^[A-Z]*$/;
return re.test(value);
}
// -->
</SCRIPT>
</head>
<body>
<FORM NAME="KeyTest">
<input type="text" id="myText" onkeypress="keytest(event,AZ);" onkeyup="followup(this.id)" onfocus="lastval=this.value;">
<br><br>
<input type="text" id="myText2" onkeypress="keytest(event,AZ);" onkeyup="followup(this.id)" onfocus="lastval=this.value;">
</FORM>
</body>
</html>