<HTML>
<HEAD>
<TITLE>Text Object Select/Focus</TITLE>
<SCRIPT LANGUAGE="JavaScript">
function isNumber(inputStr) {
for (var i = 0; i < inputStr.length; i++) {
var oneChar = inputStr.charAt(i)
if (oneChar < "0" || oneChar > "9") {
alert("Please make sure entries are integers only.")
return false
}
}
return true
}
function checkNumeric(fld) {
var inputStr = fld.value
if (isNumber(inputStr)) {
// statements if true
} else {
setTimeout("doSelection(document." + fld.form.name + ". " + fld.name + ")", 0)
}
}
function doSelection(fld) {
fld.focus()
fld.select()
}
</SCRIPT>
</HEAD>
<BODY>
<FORM NAME="entryForm" onSubmit="return false">
Enter any positive integer: <INPUT TYPE="text" NAME="numeric"><P>
<INPUT TYPE="button" VALUE="Verify" onClick="checkNumeric(this.form.numeric)">
</FORM>
</BODY>
</HTML>
|