Using angular js form validations in <form:input> tag

人走茶凉 提交于 2019-12-24 16:48:02

问题


I have created a jsp page having a spring form. I want to validate the form using angular js. When I try to add required and ng-model attributes inside <form:input> tag, I'm getting exception Jasper exception equal symbol expected and Attribute ng-model invalid for tag input according to TLD in the line where i added these attributes.

What is the procedure to make my logic work?


回答1:


There are 4 things you can try:

First one: Probably the neatest, and I think this should work:

<form:input path="usrname" maxlength="12" required="required"/>

So required='required' instead of just required

Second one: Forget about Angular Validation, and use Spring Validation methods. Maybe this isn't the thing you're searching for.

Third one: Isn't it possible for you to forget about <form:input> tags, and use <input> tags instead? Maybe not.

Fourth one: You can try to give your form:input tag an id, and at the bottom of your page, run a simple jQuery script. I know, this isn't the neatest thing to do, but maybe it works.

<html>
    <body>
        <form:input path="someinput" id="someinput"/>
    </body>
<script>
        $("#someinput").attr('required', ''); 
</script>
</html>

Please mark this as an answer if this helped you.



来源:https://stackoverflow.com/questions/27717836/using-angular-js-form-validations-in-forminput-tag

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!