Garg Garg - 1 year ago 67
HTML Question

HTML Form is submitted without to be populated on iOS devices

I have simple html form on my site:

<form action="mailer.php" method="post">

<div class="column-50">

<label for="name">Name <span>*</span></label>
<input type="text" id="name" name="name" required>
<span class="mf-error-message">Error! </span>



<label for="email">Email <span>*</span></label>
<input type="text" id="email" name="email" required>
<span class="mf-error-message">Error! </span>

.... // some more fields
<input type="submit" id="submit" name="submit" value="Enter your Information">

The problem is that on iOS devices ( phone, tablet .. ) form it can be submitted without user to populate required fields.

Why is that? Is there a way to fix it on client side?

Answer Source

This should work. But it will be for all not only for iOS

<form action="mailer.php" method="post" id="myForm">

Then this

var form = document.getElementById('myForm'); 
     form.noValidate = true;
     form.addEventListener('submit', function(event) {  
        if (! {
             alert('Error! You must fill all required fields.');             
}, false);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download