js check function, checking empty string, null, undefined, etc.

Js sharing a verification function, and can verify null and undefined "" and "" if the time is not returns true, otherwise returns false

/**
 * 为空校验函数校验undefined、null以及空字符串等
 */
var isNotNull = function (obj){
    var result = true;
    /*进行校验*/
    switch (obj) {
        case undefined:
        case  null:
            result = false;
            break;
    }
    if(result){
        if(obj.replace(/\s+/g,"") == ""){//空字符串校验
            result = false;
        }
    }
    return result;
}
Published 37 original articles · won praise 29 · views 10000 +

Guess you like

Origin blog.csdn.net/qq_42755868/article/details/86664936