How is the "check" made for this to check if a textfield is empty?
Jquery:
$("#AddGoogleMap").click(function () {      
    if($('#googleMapCity').val()==null) {
        alert("You need to fill out a city");
    } else {
     // do something
    }
How is the "check" made for this to check if a textfield is empty?
Jquery:
$("#AddGoogleMap").click(function () {      
    if($('#googleMapCity').val()==null) {
        alert("You need to fill out a city");
    } else {
     // do something
    }
 
    
     
    
    First, remove the whitespace from the beginning and end of a string and then compare the value with the empty string, like:
if( $.trim($('#googleMapCity').val()) === '') {
     alert("You need to fill out a city");
} else {
 // do something
}
 
    
    if($('#googleMapCity').val() === "") {
 alert("You need to fill out a city");
}
 
    
     $("#AddGoogleMap").click(function () {      
    if($('#googleMapCity').val()==='') {
    alert('You need to fill out a city');
     } else {
     // do something
     }
 
    
    $("#AddGoogleMap").click(function () {      
    if($('#googleMapCity').val() === "") {
        alert("You need to fill out a city");
     } else {
     // do something
     }
});
