stopping form submit if the validation fails.

后端 未结 7 2252
青春惊慌失措
青春惊慌失措 2020-12-05 21:17

I am validating the dates in below function. If the validation fails, then the form should not get submitted. I tried returning false in form onsubmit but it still gets subm

7条回答
  •  执笔经年
    2020-12-05 22:22

    use return on the onclick attribute in the form tag attribute onsubmit="return validateForm()" , if you return false in your validation function in javascript if the input is incorrect then you have to add return to your onclick attribute in order for it to execute .Hope it helped someone!

提交回复
热议问题