Client Script on Modal not alerting

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2024 10:00 AM
I have a function in a modal where if the choicelist is Other(value 3) it checks to make sure the text area below has text entered. If the text area has something, I need it to return true and continue back in the previous function.
Right now, if nothing is selected in the choicelist, the alert pops correctly, but if the choiclist is Other and the text field is blank, it does NOT fire the alert. This is the function in the Client Script portion of the UI Page.
function validateComments() {
var earlyReason = gel('EarlyReason').value;
var earlyText = gel('otherComment').value;
//Make sure dialog comments are not empty
if (earlyReason == "") {
//If comments are empty stop submission
alert("Select the early change reason before continuing.");
return false;
}
else if ((earlyReason == 3) && (earlyText == '' || earlyText == null)) {
alert("You must provide detail why you are releasing early.");
return false;
}
else {
return true;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2024 10:08 AM
check typeof for earlyReason if that is coming as string try
else if ((earlyReason == '3') && (earlyText == '' || earlyText == null))

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2024 05:21 AM - edited 05-28-2024 05:27 AM
I checked and it is coming back as a string. What's interesting is that I tested the length on an empty value and it comes back as comment.length == 1. I'm not sure why that is, but your typeof helped point the way.