locked
Form Invalid event doesn't get fired

    Question

  •  Form level "invalid" event doesn't get fired in windows store app using javascript, however it is firing for each invalid element.

    below is the W3c document regarding this specification 

    When a form is submitted, invalid events are fired at each form control that is invalid, and then at the form element itself. This can be useful for displaying a summary of the problems with the form, since typically the browser itself will only report one problem at a time.

    http://www.w3.org/TR/html5/forms.html#the-form-element


    Thanks Kumar Gaurav

    Sunday, April 27, 2014 7:52 AM

All replies

  • Hi Kumar Gaurav,

    Would checkValidity() for the form helps?

    The invalid is not a bubble event, could be handled by some controls.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.


    Monday, April 28, 2014 5:24 AM
    Moderator
  • Thanks for your reply,

    I have a basic login control that has user name and password is required and i have attached form's submit event now when i click on submit button it shows me user name and password field as required and event is not going to form's submit block. i know that checkValidity will also fire the validations but browser is not firing form's submit event if any of field is invalid, means browser first check for invalid itself and if all of the fields are valid than it goes to submit event of form.

    Thanks


    Thanks Kumar Gaurav

    Monday, April 28, 2014 7:39 AM
  • @Kumar Gaurav, the oninvalid event gets triggered at the form level only during the capturing phase, not during the bubbling phase. However, the oninvalid event gets triggered for individual controls - such as textboxes for both the phases.

    When validating fields as per the above, if you have the oninvalid event handlers registered or fields are required, then the form submit event will not be triggered unless you complete the validation. What exactly are you looking for?


    Windows Store Developer Solutions, follow us on Twitter: @WSDevSol|| Want more solutions? See our blog

    Friday, May 9, 2014 11:50 PM
    Moderator