18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
How do I check if a string is empty or not?
function check($arg)
{
//here i want to check $arg is empty or not
}
check(""); //contain no space
check(" "); //contain space
can i use isBlankOrNull($arg)
Thanks Advance
{
//here i want to check $arg is empty or not
}
check(""); //contain no space
check(" "); //contain space
can i use isBlankOrNull($arg)
Thanks Advance
This discussion has been closed.
Comments
i am doing like
var $StrToCheck= $arg.replace(/^\s+|\s+$/, '');
//then we check for the length of the string if its 0 or not
if( StrToCheck.length==0) {
return true;
}
else
return false;
Any other way for same .
Thanks
Paresh
I am not sure what your intention is. Could you specify what check("") and check(" ") should return?
Regards,
Narayan
here i want to check function argument in called function( getTab) is contain string,space or nothing
function getTab($arg)
{
//here i want to check argument string if it's contain nothing (case 1) or space(case 2) then i want to return false and if it's contain string (case 3)then return true
}
case 1 : getTab("") ; //here passing nothing between parentheses
case 2: getTab(" "); //here passing space between parentheses
case 3: getTab("hi"); //here passing string between parentheses
function isBlank($arg)
{
return $arg.replace(/^\s+|\s+$/g, '') == "";
}
Some tips:
1) Always name the function correctly (so that you understand what it means when you look at it 2 months later)
2)
if (condition) {
return true;
} else {
return false;
}
is the same as
return condition;
Regards,
Narayan