- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2023 09:47 PM
Hi all,
In catalog client script, when value is empty or null, how to deal in if condition?
eg:
Var val; //or val='' whatever. But it is empty
if(val != null || val !=''){ //its not working.
alert(val);
}
So, how to deal empty variable?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2023 09:53 PM
when you have two "NOT" conditions always use && between them instead of ||.
Try below:
Var val;
if(val !='' && val !=null){
alert(val);
}
Please mark the answer correct/helpful accordingly.
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2023 09:53 PM
when you have two "NOT" conditions always use && between them instead of ||.
Try below:
Var val;
if(val !='' && val !=null){
alert(val);
}
Please mark the answer correct/helpful accordingly.
Raghav
MVP 2023

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2023 09:53 PM - edited 01-02-2023 09:55 PM
Try below if condition if var is empty
if(!var){
//your code
}
Please mark as correct answer if this solves your issue.