Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

radio button on ui page

Rj27
Mega Guru

Hi,
I have 2 radio buttons on my ui page with options yes/no.
I want to make this mandatory and allow only one value to be selected at time.
Currently, both options are getting selected.
My code :

<label>select your option </label><br/>
<input type="radio" name="yes" id="yes" value="Yes">Yes</input><br/>
<input type="radio" name="no" id="no" value="No">No</input><br/>

 

find_real_file.png

1 ACCEPTED SOLUTION

@Rj27 

for mandatory add required="true" to one of the tag

<label>select your option </label><br/>
<input type="radio" name="my_button" id="yes" value="Yes" required="true">Yes</input><br/>
<input type="radio" name="my_button" id="no" value="No">No</input><br/>

OR

try this

<label>select your option </label><br/>
<input type="radio" name="my_button" id="yes" value="Yes" required>Yes</input><br/>
<input type="radio" name="my_button" id="no" value="No">No</input><br/>

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

6 REPLIES 6

suvro
Mega Sage

Have only one radio button. If selected YES otherwise consider it as NO. Change the label from Select your option to a question whether to select Yes

Charles Louis1
Giga Expert

PLease try this 

<label>select your option </label><br/>

<input type="radio" name="yes_no" id="yes" value="Yes">Yes</input><br/>

<input type="radio" name="yes_no" id="no" value="No">No</input><br/>

 

Please Mark this as correct if its helpful.

 

how can i make this mandatory ? becasue these two are two different radio buttons. At the time of my submit i have to check either one of them is checked as true .

you just need to add  required=true