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

Q197 How do I detect if text has been entered on a text input before the form has been submitted?

You are here: irt.org | FAQ | JavaScript | Form | 3.4 | Q197 [ previous next ]

<script language="JavaScript"><!--
function validate() {
    if document.myForm.myText.value = '' {
        alert('Form field blank!');
        return false;
    }
    else
        return true;
}
//--></script>

<form name="myForm" onSubmit="return validate()">
<input type="text" name="myText">
<input type="submit">
</form>

Feedback on 'Q197 How do I detect if text has been entered on a text input before the form has been submitted?'

©2018 Martin Webb