Text Object Select and Focus : TextField : Form Control JAVASCRIPT DHTML TUTORIALS


JAVASCRIPT DHTML TUTORIALS » Form Control » TextField »

 

Text Object Select and Focus



<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>

           
       



-

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

JAVASCRIPT DHTML TUTORIALS

 Navioo Form Control
» TextField