- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2022 11:44 PM
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/>
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2022 12:05 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2022 11:57 PM
Hi,
since you have given different value for your name attribute it's allowing you to select both
Ensure you keep the name attribute same
<label>select your option </label><br/>
<input type="radio" name="my_button" id="yes" value="Yes">Yes</input><br/>
<input type="radio" name="my_button" id="no" value="No">No</input><br/>
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2022 12:05 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader