Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

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

irt.org | Knowledge Base | JavaScript | Form | Q1453 [ previous next ]

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

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>

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.