2
I was trying to find a better title for this question, but I still don’t quite know how to explain it, but come on.
I have a simple form with three fields, if I miss one of them will be shown a tooltip saying that the field needs to be filled in correctly, so far so good, I correct the information in the form and send, when I submit the validations fle all red inputs looking like I had twice submitted the form, this behavior only happened in Firefox for both Macbook and Windows, tested in version 46.
Example:
var form = document.getElementById("Form");
var time = document.getElementById("Time");
form.onsubmit = function() {
console.log('test');
this.reset();
time.focus();
return false;
};
<form id="Form">
<fieldset>
<legend>New Item</legend>
<label for="Time">Time:</label>
<input type="text" required="" autofocus="" pattern="[0-9]{1,2}" placeholder="Time spend" name="Time" id="Time">
<label for="Type">Action:</label>
<select required="" name="Type" id="Type">
<option value=""></option>
<option>Run</option>
<option>Swimming</option>
<option>Bike</option>
<option>Drink</option>
<option>Eat</option>
<option>Crossfit</option>
<option>Yoga</option>
</select>
<label for="Date">Date:</label>
<input type="text" required="" pattern="(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d" placeholder="dd/mm/aaaa" name="Date" id="Date">
<button class="add" type="submit">Add</button>
</fieldset>
</form>
Link in jsfiddle
It’s because the property required is understood in different ways by browsers.
– Diego Souza
You want to know what’s going on, how to fix it or both?
– Randrade
@Randrade the two, understand the problem and know how to solve haha
– Gabriel Rodrigues
I do not know if I understand the question, if you have not reached the point you wanted, just say that I improve the answer.
– Randrade