HTML/[removed] Simple form validation on submit

后端 未结 6 2156
北荒
北荒 2020-11-29 05:40

I\'m trying to validate my form with the easiest way possible, but somehow it is not working and when I click submit it just takes me to the next page without giving the ale

6条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-29 06:10

    I use this really simple small JavaScript library to validate a complete form in one single line of code:

     jsFormValidator.App.create().Validator.applyRules('Login');
    

    Check here: jsFormValidator

    The benefit of this tool is that you just write a JSON object which describe your validation rules. There isn't any need to put in a line like:

     
    

    data-validate is injected in all the input fields of your form, but when using jsFormValidator, you don't require this heavy syntax and the validation will be applied to your form in one shot, without the need to touch your HTML code.

提交回复
热议问题