1. Test application for the current senario
Here is the test application I created for your scenario: Plunker1
Below, the CSS class is used to highlight the required input fields that did not pass the test:
.submitted input:invalid { border: red 1px solid; }
Running this in IE 10 and Chrome 32 does not have the desired effect. Default value: Invalid CSS is applied to invalid fields. This is not the one defined by the CSS user. This eliminates the possibility that IE and Chrome behave differently in the object script.
2. Revelations from Internet research
Following the example here , I created another test application here: Plunker2 This works fine in both IE 10 and Chrome 32.
Essentially, we remove the default form validation for submission and add a custom validation that uses user-defined CSS.
HTML changed:
<button formnovalidate="" type="submit">Submit</button>
Javascript
document.addEventListener("DOMContentLoaded", function() { document.forms[0].addEventListener('submit',function(e){ e.preventDefault(); e.currentTarget.classList.add('submitted'); }); });
Note You can also use window.onload instead of the DOMContentLoaded event.
We hope that this helps in solving the problem that you are facing.
Bhanu devapatla
source share