Expand my Community achievements bar.

SOLVED

Check for text in a text field and make checkbox mandatory

Avatar

Level 7

I have a text field where if the user has entered a value, then the checkbox that follows must be mandatory. I have this script that works (sort of), but I'm not sure which event to use to get the results I want. I want the message and the checkbox to be mandatory only if something is typed in the field.

Here's the script:

 

if ((this.rawValue != "null") || (this.rawValue != ""))
{
     CheckBox3.mandatory = "error";
     app.alert("Please indicate that you have reviewed the similar profile and approve it");    
 
}

else if ((this.rawValue == "null") || (this.rawValue == ""))
{
     CheckBox3.mandatory = "disabled";
}

Thanks,

MDawn

1 Accepted Solution

Avatar

Correct answer by
Level 7

you can put your script in the exit event of text field.

View solution in original post

3 Replies

Avatar

Correct answer by
Level 7

you can put your script in the exit event of text field.

Avatar

Level 7

That worked. Thank you. I have another problem now. If the user deletes the information typed in the text field, the message box still displays and the checkbox is still outlined in red indicating it's required and it shouldn't be.

Thanks,

MDawn

Avatar

Level 7

It shouldn't - perhaps they are still leaving spaces which would count as not being null. You could put an extra condition this.rawValue != " " or something like that.