0

在一个页面中,我有两个单选按钮,基于哪个单选按钮,我将使用名为“person”和“organization”的类在此页面中显示一些控件。此外,我想检查用户在输入文本控件中输入的数据是否正确。如何在客户端验证数据?例如:

<input runat="server" id="txtnationalid" maxLength="10" name="txtnationalid" class='person ltr glow-onfocus customerCode required number' dir="ltr" />
<asp:RequiredFieldValidator Display="Dynamic" runat="server" ID="txtcodecv1" ErrorMessage="it can not be null" ControlToValidate="txtnationalid" ></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ValidationExpression="[0-9]{10}" Display="Dynamic" runat="server" id="txtcodev2" ErrorMessage="it's not in correct format" ControlToValidate="txtnationalid" ></asp:RegularExpressionValidator>
<input runat="server" id="txteconomiccode" maxLength="15" name="txteconomiccode" class='organization ltr glow-onfocus customerCode required number' dir="ltr" />
<asp:RequiredFieldValidator Display="Dynamic" runat="server" id="txtcodecv3" ErrorMessage="economiccode required" ControlToValidate="txteconomiccode"></asp:RequiredFieldValidator>                         
4

1 回答 1

0

你可以为此使用 jQuery

  <script>
  $(document).ready(function(){
    $("#commentForm").validate();
  });
  </script>

</head>
<body>


 <form class="cmxform" id="commentForm" method="get" action="">
   <input type="text" name="firstName" class="required"/>
 <input type="submit" value="submit"/>
 </form>
</body>
</html>

有关模式详细信息,请参见此处

于 2013-03-04T12:25:56.180 回答