setMandatory is not working in my onchange script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2016 03:43 AM
This my onChange Client script that makes the comment field mandatory if correct state is selected.
My problem is that if i select state(1,2,4) the comment field will become mandatory and I select state(3), it wont become mandatory.
Could you help me on this, i don't know the root cause of this script because they are in the same IF.
Here is my code:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var state = newValue;
if(state == '1' || state == '2' || state == '3' || state == '4'){
form.setMandatory('comments', true);
}
}
thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2016 12:56 AM
I already did that and alerts for the all the state with correct value but still the comment is not mandatory.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2016 01:54 AM
If the alerts are firing as intended and as per logic, then only issue will be name of "Catalog variable". Is the name is exactly "comments"?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2016 05:15 AM
Hi John,
I hope your form's current state value is not 3 when you test this. If so, Client script will not apply to that form, since you are running Onchange client script on the field state.
Here I would suggest to try by removing the below two lines of code in your client script and check once.
if (isLoading || newValue == '') {
return;
}
Regards,
Gowthaman Balu.