i find this thread here and works perfect for me but i want to evolve a little and to old.. and idk if i will receive any anwsers.. so i need a quick help. i use this code and works perfect:
HTML:
<form action="mail.php" method="POST" onsubmit="return foo(this);">
<input type="text" name="full_name" value="" required>
<button type="submit">submit form</button>
</form>
JavaScript:
function foo(form){
$.ajax({
url: $(form).attr('action'),
type: 'POST',
data: $(form).serialize(),
success: (res)=>{
// success...
console.log(res);
},
error: (err)=>{
// error...
console.error(err);
},
complete: ()=>{
// something here...
}
});
return false;
}
but i want to integrate also this:
<script>
$(document).ready(function(){
//alert("b");
jQuery("#a").css("background-color", "#ffebed");
jQuery("#a").css("border", "2px solid #ff3f4c");
setTimeout(function(){
//alert("hello");
jQuery("#a").css("background-color", "#fff");
jQuery("#a").css("border", "1px solid #f4f4f4");
$("#invalidmsg").hide();
$("a").val('');
$("a").val('');
$("a").val('');
document.getElementById("a").reset();
}, 2000);
});
</script>
after i submit the button i want your help guys to extract/integrate from this javascript after i submit the button to make the input red and reset after 2 sec like here. and also bellow the input a text like "12345"
and sorry for my bad english. im not expert..