I have two Radio Buttons that I want when clicked on (either one) to make a Number Field mandatory. I have viewed many websites on setting a mandatory field but the script I am using will not work. I have tried a couple ways of writing it but I seem to be missing something.
I have used this script in the Show of: click & change
Here is the script that I'm using right now.
if (this.rawValue==1)
{
AssemblyNu-1.mandatory ="error";
}
else
{
AssemblyNu-1.mandatory ="disabled";
And this one:
if (this.rawValue==2)
{
AssemblyNu-1.mandatory ="error";
}
else
{
AssemblyNu-1.mandatory ="disabled";
Thanks,
HHud5757
Views
Replies
Total Likes
So, I put a quick form together to test your code.
On the change event of the radio button list (not the radio button itself), I added:
if (this.rawValue == 1) tfTest.mandatory = "error";
else tfTest.mandatory = "disabled";
In my case, the radio button with the value of 1 is the one I want to make the field mandatory. If you want either button to make it mandatory, then use:
if (this.rawValue == 1 || this.rawValue == 2) tfTest.mandatory = "error";
Views
Replies
Total Likes
Great I will give this a try.
I have used
if(this.rawValue ==1 || ==2) but I did not add the this.rawValue
Does the tf in the tfTest.mandatory ="error"; mean true or false? I am learning this JavaScrpt as I go along.
Thanks for your help.
Views
Replies
Total Likes
tf is just part of the name of the field. Since you can't see what I've got in my form, I used that to indicate it was a text field. e.g., tf = text field, btn = button, cb = check box. With a prefix, if someone is looking at script, they can easily determine what object type is being referenced.
Views
Replies
Total Likes
I would recommend using checkboxes instead of radio buttons for things like this. They act a little less quirky, and it's easy to set them to uncheck the other boxes as needed.
Try this script on the change event (javascript):
if (this.rawValue == "1") { //if the checkbox is checked
AssemblyNu-1.mandatory = "error"; //make field mandatory
OtherCheckbox.rawValue = "0"; //uncheck other checkbox
} else { //if the checkbox is not checked
AssemblyNu-1.mandatory = ""; //field is not mandatory
}
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies