This should be the entry level JS article, we JS determine whether the variable is an empty example of a brief introduction. <!doctype HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd" > <html xmlns= "http://www.w3.org/1999/xhtml" > <head> <meta http-equiv= "Content-type" content= "HTML; charset=gb2312 "/> <TITLE>JS determine whether the variable is empty </title> <script> function S () { var Tt=document.getelementbyid ("DW"). Value; Alert (TT); if (Tt==null | | tt== "") { Alert ("Input, can not be empty Oh"); } else{ Alert (TT); } return false; }
That affirmative variable is not empty Ah, teach you a way that you write:
function S () { var Tt=document.getelementbyid ("DW"). Value; SSSSSS ()//program run this will be the error, click Debugging, with Debugging tools to follow up to see what the situation if (tt!=null) { Alert ("Bukong"); } else{ Alert ("Kong"); } }
Also, attach a method to determine whether it is empty:
var isnull = function (obj) { Try{return Obj==0?false:!obj}catch (e) {return false;} }
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.