I have some fields which I want to submit to database via jquery post method. I also want to check that if they are filled or not so i am using this code-
$("#rpsub").click(function(){
var rt = $("#rt").val();
var ao = $("#ao").val();
var impl = $("#impl").val();
var rteam = $("#rteam").val();
var con = $("#con").val();
if(rt != "" && ao != "" && impl != "" && rteam != "" && con != ""){
$(this).unbind("click");
$(this).val("Loading...");
$(this).css({
"padding": "3px",
"font": "14px calibri",
"color": "#fff",
"background": "grey",
"border": "1px solid #666666",
});
if(document.cookie.indexOf("trda") == -1){
}else{
$.post("./inc/rp.php", {func:"submit", login:'true', user:getcookie("trda"), rt:rt, ao:ao, impl:impl, rteam:rteam, con:con}, function(data){
if(data != ""){
window.location = "thankx.php";
}
});
}
}else{
alert("Please fill every field to continue");
}
});
(I have made getcookie function.)
The problem is that when execute the program it does not consider the if statement where i check that they are filled or not. it execute the whole script when the fields are empty.
Aucun commentaire:
Enregistrer un commentaire