HTML5 input required, scroll to input with fixed navbar on submit

前端 未结 9 2055
感情败类
感情败类 2020-12-08 09:35

When trying to submit a form with missing required fields, my browser (Chrome), displays a message mentionning there is a field missing, and if it\'s out of my screen, it sc

9条回答
  •  攒了一身酷
    2020-12-08 09:42

    You can use oninvalid event attribute of HTML5 and in your script's tag write a function for redirecting it.

    Here is the example:

    
    
    
    

    And on clicking on your submit button it will scroll to the invalid field.

    For radio button please add only on one radio with same name
    Here is the example (jsfiddle)

提交回复
热议问题