How to submit form with anchor tag/ href/a click in jquery?
Reload and Reset form jquery?
Simple validation in Jquery
// bind "click" event for links with title="submit"
$("a#submitcontact").click( function(){
// it submits the form it is contained within
$(this).parents("#register-form").submit();
});
$("#register-form").submit(function() {
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
//$("#inline").empty().append('abc');
var address = $("input[name=Email]").val();
var emailError = true;
if($("input[name=Nama]").val() == ''){
$("#inline").empty().append('Please enter your Name.');
$('#Nama').focus();
return false;
}
else if($("textarea[name=Alamat]").val() == ''){
$("#inline").empty().append(' Please enter your Alamat');
$('#Alamat').focus();
return false;
}
else if($("input[name=Email]").val() == ''){
$("#inline").empty().append(' Please enter your E-mail address');
$('#Email').focus();
return false;
}
else if(!reg.test(address)) {
//emailError = true;
$("#inline").empty().append('Please enter your valid E-mail address.');
$('#Email').focus();
return false;
}
else if($("input[name=NoTelp]").val() == ''){
$("#inline").empty().append('Please enter your NoTelp.');
$('#NoTelp').focus();
return false;
}
else if($("textarea[name=Pesan]").val() == ''){
$("#inline").empty().append(' Please enter your Pesan');
$('#Pesan').focus();
return false;
}
else{
return true;
}
});
$("a#reseter").click( function(){
// it submits the form it is contained within
//opener.location.reload(true);
window.location.href = "contact.html";
// $(this).closest('form').find("input[type=text], textarea").val("");
// $(this).parents("#register-form").reset();
});
});
No comments:
Post a Comment