驗證用戶輸入非空的函數

//判斷是否爲空,如果爲空返回true,否則返回false
function isEmpty(text) {
if (text == undefined || text == null || text == '' || text == 'null' || text == 'undefined') {
return false;
} else {
text = text.replace(/(\s*$)/g, '');
if (text == '') {
return false;
}
}
return true;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章