ajax - JQuery working on jsfiddle but not on my server -


i have simple script validates inputs , shows error messages. here jsfiddle http://jsfiddle.net/2kjvu/

dom loaded, script embedded. code working partially e-mail message showing on website, if email field filled out correctly. js:

$(document).ready(function(){     $('#registreren').click(function(){           var email = $('#email').val();         var postcode =$('#postcode').val();          $("#add_err2").html("");          if(email == "") {             $("#add_err2").css({"border-radius":"5px", "background":"#fd7777", "border":"1px solid #ff0000"});             $("#add_err2").html("vul a.u.b. een e-mail adres in <br>");         }         else if(!validateemail(email)){             //$("#add_err2").css({"border-radius":"5px", "background":"#ff4e4e", "border":"1px solid #ff0000"});             $("#add_err2").append("vul a.u.b. een geldig e-mail adres in <br>");         }          if(postcode == "") {             //$("#add_err2").css({"border-radius":"5px", "background":"#ff4e4e", "border":"1px solid #ff0000"});             $("#add_err2").append("vul a.u.b. een postcode in <br>");         }         else if(postcode.length < 4){             //$("#add_err2").css({"border-radius":"5px", "background":"ff4e4e", "border":"1px solid #ff0000"});             $("#add_err2").append("vul a.u.b. een geldige postcode in <br>");         } else {             // send backend service;             $.ajax({                 type: "post",                 url: "./postcodecheck.php",                 data: "registreren=true&email="+email+"&postcode="+postcode,                 success: function(html){                         if(html=='true')    {                         $("#add_err2").hide();                         window.location="./registreren.php";                     }                     else    {                         $("#add_err2").css({"border-radius":"5px", "background":"#496999", "border":"1px solid #174385", "width":"350px;", "color":"#ffffff"});                         $("#add_err2").html("helaas boxcloud nog niet beschikbaar in uw regio. als u op de hoogte wilt blijven van nieuwe regio’s, meld u dan a.u.b. via de onderstaande balk aan voor de nieuwsbrief van boxcloud");                     }                 },             });             function validateemail(email) {                 var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-za-z\-0-9]+\.)+[a-za-z]{2,}))$/;                 return re.test(email);             }             return false;         };     }); }); 

html:

<form id="klant_worden" action="" method="post">     <fieldset id="inputs">         <input id="email" type="email" name="email" class="inputs" placeholder="uw e-mail adres">         <input id="postcode" type="text" name="postcode" class="inputs" placeholder="uw postcode (1234ab)">         <!-- <input type="submit" class="submitclient" id="registreren" value="registreren" name="registreren" onclick="validateform();"> -->         <input type="button" class="submitclient" id="registreren" value="registreren" name="registreren">     </fieldset> </form>  <section class="err" id="add_err2"><br></section> 

this working fine there not on server. why?

edit:

live version can found here(first signup box): http://www.boxcloud.nl/site/

validate email should outside else loop: http://jsfiddle.net/2kjvu/3/

$(document).ready(function () {     $('#registreren').click(function () {         var email = $('#email').val();         var postcode = $('#postcode').val();          $("#add_err2").html("");          if (email === "") {             $("#add_err2").css({                 "border-radius": "5px",                     "background": "#fd7777",                     "border": "1px solid #ff0000"             });             $("#add_err2").html("vul a.u.b. een e-mail adres in <br>");         } else if (!validateemail(email)) {              $("#add_err2").append("vul a.u.b. een geldig e-mail adres in <br>");         }          if (postcode === "") {             $("#add_err2").append("vul a.u.b. een postcode in <br>");         } else if (postcode.length < 4) {             $("#add_err2").append("vul a.u.b. een geldige postcode in <br>");         } else {             // send backend service;             $.ajax({                 type: "post",                 url: "./postcodecheck.php",                 data: "registreren=true&email=" + email + "&postcode=" + postcode,                 success: function (html) {                     if (html == 'true') {                         $("#add_err2").hide();                         window.location = "./registreren.php";                     } else {                         $("#add_err2").css({                             "border-radius": "5px",                                 "background": "#496999",                                 "border": "1px solid #174385",                                 "width": "350px;",                                 "color": "#ffffff"                         });                         $("#add_err2").html("helaas boxcloud nog niet beschikbaar in uw regio. als u op de hoogte wilt blijven van nieuwe regio’s, meld u dan a.u.b. via de onderstaande balk aan voor de nieuwsbrief van boxcloud");                     }                 }             });           }     });      function validateemail(email) {         var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-za-z\-0-9]+\.)+[a-za-z]{2,}))$/;         return re.test(email);     }   }); 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -