Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q777 How can I constantly check to see if and when the user has entered a specific word in a text box?

You are here: irt.org | FAQ | JavaScript | Form | 6 | Q777 [ previous next ]

You need a polling JavaScript function that doesn't tie up the browser, but returns control back to the browser for a while they checks again:

<FORM NAME="myForm">
<INPUT TYPE="TEXT" NAME="myText">
</FORM>

<SCRIPT LANGUAGE="JavaScript"><!--
function monitorText() {
    if (document.myForm.myText.value.indexOf('skip') > -1)
         alert('detected skip');
    else
        setTimer('monitorText()',1000); // checks field every 1000 milliseconds
}

monitorText();
//--></SCRIPT>

©2018 Martin Webb