As ocistiti the form is modal window fancybox, after closing (close) and the result send?

All of the code.
function validateEmail(email) { 
 var reg = /^(([^<>()[\]\\.,;:\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 reg.test(email);
}

 $(document).ready(function() {
$(".modalbox").fancybox();
 $("#for").submit(function() { return false; });


 $("#sendz").on("click", function(){
 var emailval = $("#email").val();
 var msgval = $("#name").val();
 var msglen = msgval.length;
 var mailvalid = validateEmail(emailval);

 if(mailvalid == false) {
$("#email").addClass("error");
}
 else if(mailvalid == true){
$("#email").removeClass("error");
 } 
 if(msglen < 4) {
$("#name").addClass("error");
}
 else if(msglen >= 4){
$("#name").removeClass("error");
 } 
 if(mailvalid == true && msglen >= 4) {
$("#sendz").replaceWith('Text');
$.ajax({
 type: 'POST',
 url: 'filephp.php',
 data: $("#form").serialize(),
 success: function(data) {
 //Clears all the form after submit
setTimeout("$.fancybox.close()", 7000);
$('#form').find('input[type=text],input[type=tel],input[type=email], textarea').val(");
$('#rorm').find("input[type=checkbox], input[type=radio]").prop("checked", "");

console.log(data); 
$('#form').html(data);// Output result filephp.php which is repeated after the re-launch of Thomas.
}
});
}
});
 });
March 19th 20 at 08:23
1 answer
March 19th 20 at 08:25
Solution
To solve such issues, you need to see your code or at least the version of fancybox.
But if you will be enough that that made the example:


Before opening the window, get ID of window you have open, find in it all the input and clean it:
$("[data-fancybox]").fancybox({
 beforeShow: function( instance, slide ) {
$(slide.src).find('input').val(");
}
});

Or apply reset() to the form
/*! fancyBox v2.1.3 fancyapps.com | fancyapps.com/fancybox/#license */

1. Fill out the form, just close the window (close) . Open again, the form has not been filled.
I would like the form to clear.
2. And again. Produce mandrel, everything is fine, everything went. Again I want to open a modal window, but displays the result of sending.

Here is the piece of code.

$(document).ready(function() {
$(".modalbox").fancybox();
 $("#form").submit(function() { return false; });


 $("#form").on("click", function(){
 var emailval = $("#email").val();
 var msgval = $("#name").val();
 var msglen = msgval.length;
 var mailvalid = validateEmail(emailval); All issues after. If I am still on this page.


Validation

$.ajax({
 type: 'POST',
 url: 'phpfile.php',
 data: $("#form").serialize(),
 success: function(data) {
setTimeout("$.fancybox.close()", 7000);
 clearing form after submit
$('#form')[0].reset();

console.log(data); 
$('#form').html(data);
}
});
}
 });
- ludwig.Leann commented on March 19th 20 at 08:28

Find more questions by tags HTMLjQuery