admin管理员组文章数量:1430083
I'm new to Javascript and HTML and am trying to do some form validation. When the validation() fails for some input like
<input type="text" name="firstName" />
I'd like to have an error message show next to the field that was in error. How do I find the location of where to put the message? Or do I have some sort of label that's hidden to set when there is an error? Thanks.
I'm new to Javascript and HTML and am trying to do some form validation. When the validation() fails for some input like
<input type="text" name="firstName" />
I'd like to have an error message show next to the field that was in error. How do I find the location of where to put the message? Or do I have some sort of label that's hidden to set when there is an error? Thanks.
Share Improve this question asked Oct 26, 2011 at 0:47 J WJ W 8781 gold badge12 silver badges25 bronze badges 1- 1 Why not use jQuery validation plugin? – Emmanuel N Commented Oct 26, 2011 at 0:52
1 Answer
Reset to default 3You can have a div tag such as <div id="errorMsg"></div>
, and in your javascript, when validation fails, use:
document.getElementById('errorMsg').innerHTML = "error msg";
本文标签: htmlJavascript form validationshowing error message next to ltinputgtStack Overflow
版权声明:本文标题:html - Javascript form validation, showing error message next to <input> - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745448461a2658771.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论