I was trying to add an ajax to submit the form without refreshing the page. Eventhough I added the "required" on HTML input tags, it is not validating that. I can submit the form without any values. But when I remove the ajax it worked fine.
<form action="mail.php" method="POST" id="signup">
<input id="form_name" type="text" name="companyName" class="form-control" placeholder="Company" required>
<input id="form_phone" type="tel" name="tele" class="form-control" placeholder="Number" required>
ajax
<script>
$(document).ready(function(){
$('#submit-btn').click(function(event){
// console.log('submitted')
event.preventDefault();
$.ajax({
type : "POST",
url : "mail.php",
data : $("#signup").serialize(),
success : function(data){
success();
console.log(data)
}
})
});
});
</script>
Can anyone help me with this? I appreciate your time.