0

in a page I have two radio-button which based which-one selected I will show some controls in this page by using classes called 'person' and 'organization'. Moreover, I want to check user enter correct data in input-text controls. How can I validta data in clientside? for example:

<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>                         
palaѕн
  • 72,112
  • 17
  • 116
  • 136
Farhad
  • 205
  • 1
  • 6
  • 13
  • http://stackoverflow.com/questions/9704039/enable-disable-aspvalidators-using-jquery#answer-9803857 – palaѕн Mar 04 '13 at 12:25

1 Answers1

0

you can use jQuery for this

  <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>

see here for mode details

PSR
  • 39,804
  • 41
  • 111
  • 151