我有一个表格:
<form method="post" id="update_user_info" action="/Cabinet/Edit">
<div class="modal-header">
<button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button>
<h3 id="myModalLabel">Modal Header</h3>
</div>
<div class="modal-body">
<div class="span4 clear_mp">
<div class="span2 pull-left clear_mp">
<label for="FirstName">Name</label>
<input type="text" value="John" name="FirstName" id="FirstName" />
</div>
<div class="span1 pull-right clear_mp">
<label for="CarMark">Car</label>
<input type="text" value="SUBARU LEGACY" name="CarMark" id="CarMark" />
</div>
<div class="span1 pull-right clear_mp">
<label for="Email">Email</label>
<input type="text" value="test@mail.com" name="Email" id="Email" data-val-email="The email is wrong" data-val="true" class="input-validation-error" />
</div>
<div class="span2 pull-left clear_mp">
<label for="PhoneNumber">Phone number </label>
<input type="text" value="" name="PhoneNumber" id="PhoneNumber" data-val-regex-pattern="(\+)?77[0-9]{9}" data-val-regex="The phone number is wrong" data-val="true" />
<span data-valmsg-replace="true" data-valmsg-for="PhoneNumber" class="field-validation-valid"></span>
</div>
</div>
</div>
<div class="modal-footer">
<input type="submit" value="Save" id="update_user_info" class="btn btn-large btn-primary" />
</div>
</form>
我想做以下事情:
1. 查找input
哪些有类input-validation-error
(在这里,我没有问题)
2. 获取data-val-*
(* 表示电子邮件或正则表达式或其他内容)属性的值,并显示带有此值的引导工具提示输入?
我怎样才能做到这一点?
jsFiddle上的标记