Domino JavaScript combobox validation

5 pts.
Tags:
Domino
JavaScript
Validation
I would like to ask if someone has a JavaScript code which does the validation on a combobox field. If nothing is selected, a warning pops up and reminds the user that a value has to be selected. I tried to use this code which works fine on regular text fields: if (document.forms[0].AppName.value == "") { alert("You have not selected an application. Please select an application and then continue."); document.forms[0].AppName.focus(); return false; } I would appreciate it if I can get any help on this.

Answer Wiki

Thanks. We'll let you know when a new response is added.

The value property is directly exposed on single select boxes in IE, but the proper syntax is:

document.forms[0].selectBox.options[document.forms[0].selectBox.selectedIndex].value. You have to access the value as an index of the options collection.

To trap for no option selected, you check for a selectedIndex of -1 (or <0).
I.e.,
if (f.FieldName.selectedIndex = -1 {
//alert, focus, return false here
}

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following