Hello coders,
I have an jquery form validator, client-side but also an php serverside validator.
After the form is validated client-side, it would send an ajax to my submit.php page.
If the form isn't validated server-side it would return a div with class 'error'.
Here's the code:
Ajax:
Code:
var datastring = 'username='+ username + '&password=' + password
+ '&repeatpassword=' + repeatpassword + '&email=' + email + '&formtype=' + formtype;
$.ajax({
type: "POST",
url: "submit.php",
data: datastring,
success: function(data) {
if($(data).find(".error").length > 0){
alert("Error! The following errror occurs:");
$(data).find(".error").each(function(){
$('.error_form').text($(this).text());
});
}else{
$("form.formulier").hide();
alert("succesvol signup");
//game.start(5,5);
}
alert(data);
}
});
PHP return
Code:
<div class='error'>Username does not match our conditions</div>
I want to put the text of class error, in an div with class called 'error_form'
Response:
alertbox with text: "succesvol signup"
alertbox with text: "<div class='error'>Username does not match our conditions</div>"
and div 'error_form' contained nothing
help!