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

Q1453 I want the user to be able to enter "yes" or "Yes" or YES" - what is the easiest way to accomplish this?

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

Try:

<script language="JavaScript"><!--
function fieldvalidate(formfield) {
    if (formfield.value.toLowerCase() != 'yes') {
        alert ('Please enter yes');
        formfield.focus();
        return false
    }
    return true;
}
//--></script>

<form onSubmit="return fieldvalidate(this.form.yesfield)">
<input type="text" onblur="fieldvalidate(this)" name="yesfield"> - enter "yes" to agree.
</form>

©2018 Martin Webb