How to make a field mandatory inside the widget on change of a field value in widget ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2023 01:06 AM - edited 04-12-2023 01:06 AM
there is a drop down field in a widget so when the values will be changing then i need to make a input type ="text" field mandatory , how to achieve that please advise .
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2023 01:17 AM
Hi @bala_1312,
To make field mandatory in widget, need to use html attributes required
<input type="text" id="username" name="username" required>
If my response helps you to resolve the issue close the question by Accepting solution and hit thumb icon. From Correct answers others will get benefited in future.
Regards,
Mohan.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2023 02:03 AM
Hi @Mohan raj ,
It should be dependent on dropdown field , it should not be mandatory by default .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2023 01:51 AM
Hello@debo jyoti , you can use the OnChange client script.
function DropdownChange() {
var dropdownValue = g_form.getValue('myDropdownName');
var textField =g_form.getValue('myInputFieldName');
if (dropdownValue === 'someValueYouWant') {
textField.required = true;
} else {
textField.required = false;
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2023 02:02 AM
Hi @Priyanka0402 ,
Where should i write this script ? inside client controller or is it catalog client script ?