HTML5 validation before ajax submit

前端 未结 6 1617
既然无缘
既然无缘 2020-12-01 01:38

This should be simple, yet it\'s driving me crazy. I have an html5 form that I am submitting with ajax. If you enter an invalid value, there is a popup response that tells y

6条回答
  •  盖世英雄少女心
    2020-12-01 02:01

    Not exactly sure what you mean. But I assume that you want to check in realtime if the input is valid. If so you should use .keyup instead of .click event, because this would lead to an action if the user presses submit. Look at http://api.jquery.com/keyup/

    With this you could check the input with every new character insert and display e.g. "not valid" until your validation ist true.

    I hope this answers your question!

提交回复
热议问题