Expand my Community achievements bar.

SOLVED

validating a radio button group

Avatar

Former Community Member

Hi
I have an exclusive raido button group contains "I Agree" and "I Disagree". By default I Disagree should get selected when form loads and if user clicks I Agree then only the form should submit.

Scenario i have tried:wrote script on the validation event of the radio button group but initially when the form loads, the validation fires because by defualt I disagree is selected.

Pls let me know how can i achieve this requirement?

Thanks

Abhiram

1 Accepted Solution

Avatar

Correct answer by
Level 9

Hi Abhiram,

We can use a hidden button to submit the form. In the actual submit button , if our radiobutton condition satisfies we can call the click/mouseUp event of the hidden submit button.

HiddenButton : Button type : Submit. specify the url of the mail/website you want to submit. Make it hidden/exclude from layout (As per your convenience)

Then in the actual submit button.

If (AgreementRadioButton.value == " I Disagree")

  {

     HiddenEmail.execEvent("click");

}

else

{

   app.alert("Please select I agree");

}

Note : The actual submit button would simply be a button with no submit.

Hope this will help.

Thanks.

Bibhu.

View solution in original post

3 Replies

Avatar

Level 9

Hi Abhiram,

Instead of putting the script in the validation event of the RadioButton. We can select the default value as 1 (I disagree). Then in the click/mouseUp event of the submit button we can check the value of the radioButton, If it's I agree then we can procced to the form submission, otherwise we can show an alert to the user to select the I agree option.

Thanks.

Bibhu.

Avatar

Former Community Member

ya Bhibhu.In that case we have control the form submission and cancellation through a code manually right?


Is there any code in the javascript to do that?

Thanks

Abhiram

Avatar

Correct answer by
Level 9

Hi Abhiram,

We can use a hidden button to submit the form. In the actual submit button , if our radiobutton condition satisfies we can call the click/mouseUp event of the hidden submit button.

HiddenButton : Button type : Submit. specify the url of the mail/website you want to submit. Make it hidden/exclude from layout (As per your convenience)

Then in the actual submit button.

If (AgreementRadioButton.value == " I Disagree")

  {

     HiddenEmail.execEvent("click");

}

else

{

   app.alert("Please select I agree");

}

Note : The actual submit button would simply be a button with no submit.

Hope this will help.

Thanks.

Bibhu.