Java and JavaScript comparison of hollow values and strings

Source: Internet
Author: User

JavaScript text box input value is null judgment

Verify that the name and date are NOT NULL function Checksave () {var Sname=document.getelementbyid ("Sname"). Value;var stime= document.getElementById ("dateTimePicker1"). Value;var Etime=document.getelementbyid ("Datetimepicker2"). Value;if ( sname== "") {alert ("Name cannot be empty!"); return false;} if (stime== "") | | (etime== "")) {alert ("Start or end time cannot be empty!"); return false;}}

string comparison in Java equals

if  ("". Equals (Product.getname ())  ) {                         if (product.getSmallClassId () == -9999) {                                   Specialvos= specialservice.getspecialvos (Special.getid ());                              }else{                                  Specialvos= specialservice.getspecialvos (Special.getid (), Product.getsmallclassid ());                              }        }

Non-string type

if (Special.getid () ==null) {Special.setid (IDGENERATOR.INCR (Special.class));                Special.setcreatedate (New Date ());                Special.setcreateuser ((long) 110);                Specialservice.savespecial (special); }

in struct

Background String type value if the foreground input box is not filled in empty, then the background is the empty string "", when judged with equals

Background non-string value if the foreground input box is left blank, then the background is null, when judged by = =

This article is from the "Nothing-skywalker" blog, please be sure to keep this source

Java and JavaScript comparison of hollow values and strings

Related Article

Contact Us

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: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.