I am experiencing an issue with a contact form in my HTML/PHP code. Everything seems to be working fine, but when using the SAFARI browser, the form fails to validate if I try to submit without filling out all input fields.
For example, my form includes:
<form>
<input id="txtEmail" class="formincricao" type="email" required placeholder="email" value="" name="txtEmail"/>
<input type="submit" name="btnSendInfo" value="send" id="btnSendInfo" />
</form>
The 'required' attribute does not seem to work properly in SAFARI, and even the email type validation fails to catch invalid emails.
I have tried to implement validation using JavaScript like this:
var forms = document.getElementsByTagName('form');
for (var i = 0; i < forms.length; i++) {
forms[i].noValidate = true;
forms[i].addEventListener('submit', function(event) {
//Prevent submission if checkValidity on the form returns false.
if (!event.target.checkValidity()) {
event.preventDefault();
alert('Please fill out the entire form');
//You can add your custom error message handling here.
}
}, false); }
Unfortunately, the issue still persists despite these efforts.