I'm trying to check if the value of my variable is null but it does not work. And i also have to stop script and don't insert the row
Html
<input type="text" name="for_intitule" id="form_intitule">
Jquery
var form_intitule = $('input[name=form_intitule]').val();
if(form_intitule == null){
alert('fill the blank');
return false;
}
UPDATE :
$('#insertForm').on('click', function(){
var form_intitule = $('input[name=form_intitule]').val();
if($('input[name=form_intitule]').val().trim().length == 0){
alert('fill the blank');
}
$.ajax({
type: "GET",
url: "lib/function.php?insertForm="+insertForm+"&form_intitule="+form_intitule,
dataType : "html",
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert(XMLHttpRequest + '--' + textStatus + '--' + errorThrown);
},
success:function(data){
}
});
});