Skip to Content
author's profile photo Former Member
Former Member

Mandatory Field

Hi,

I have a dropdownlistbox on my screen and a button. Some processing is performed on the click of this button. But I also want to make sure that the user has selected some value from the dropdownlistbox otherwise an error message is displayed to the user. How do I achieve this?

For Inputfields I can say REQUIRED= "TRUE". But what do I do for the dropdownlistbox?

Regards

Tejaswini

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 14, 2004 at 05:22 PM

    The dropdownlist boxes has a value by default... Try putting the "SELECTION" attribute, and then the user will be forced to select another option if the default option doesnt fit with his-her needs.

    Then if you dont want to do this, you always have the alternative of validating the fields on the server or adding some JavaScript to validate the field on the client.

    If want to code some script you should code something like this:

    function isBlank(val){

    if(val==null){return true;}

    for(var i=0;i<val.length;i++) {

    if ((val.charAt(i)!=' ')&&(val.charAt(i)!="\t")&&(val.charAt(i)!="\n")&&(val.charAt(i)!="\r")){return false;}

    }

    return true;

    }

    Then just put the "dropdownlist.value" into that function.

    Regards,

    Ariel

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 07, 2005 at 09:04 AM

    Hi Ariel,

    Thanks for the answer.It helped.

    Came back to question so late as I was working on something else 😊

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.