Ui Page:validation in ui page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2017 05:17 AM
In Client script of UI page I wrote this :
function onSubmit(){
var comm = document.getElementById('addComments').value;
//var comm = gel('addComments').value;
if(comm == ''){
alert('Please fill Comments ');
return false;
}
else{
alert(comm);
g_form.setValue('work_notes',comm);
GlideDialogWindow.get().destroy();
return true;
}
}
I am able to get the comm value.....But it is not validating for null...It always execute else part....
Could you please tell me why this condition is not met if(comm == '') ........if I am not filling anything in comment field
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2017 05:21 AM
Hi,
There seems to be a syntax error.
if(comm == '' "){
alert('Please fill Comments ');
return false;
}
Please use the highlighted part as your code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2017 05:29 AM
Hi Monu ,
There might be the case some undefined values are coming and every time it is going to else loop please try below thing :
if(comm == null)
Kind Regards,
Mayur Tejnani

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-16-2021 08:38 AM
I was stuck on the same thing and found this page. Noted that there was no real answer and I was able to solve this. So, just in case some one else comes here, I found the answer here.
function validateComments() {
//Gets called if the 'OK' dialog button is clicked
//Make sure dialog comments are not empty
var comments = gel("dial_comments").value;
comments = trim(comments);
if (comments == "") {
//If comments are empty stop submission
alert("Please provide comments to submit the dialog.");
return false;
}
I had no luck grabbing the element using "getElementById" and so I tried this. It didn't work until I add the "trim" part.
Good luck.