Jquery Validation plug-in custom error placement

后端 未结 4 658
终归单人心
终归单人心 2020-11-28 08:26

Using the jQuery Validation plug-in for the following form:

4条回答
  •  感情败类
    2020-11-28 08:57

    You can also manually add error labels in places you need them. In my particular case I had a more complex form with checkbox lists etc. where an insert or insert after would break the layout. Rather than doing this you can take advantage of the fact that the validation script will evaluate if an existing label tag exists for the specified field and use it.

    Consider:

    Now add the following line:

    which is standard error label:

    jQuery will use this label rather than generating a new one. Sorry I could not find any official documentation on this but found other posts that came across this behaviour.

提交回复
热议问题