cancel
Showing results for 
Search instead for 
Did you mean: 

Mandatory Field

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Ariel,

Thanks for the answer.It helped.

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