HTML Markup:
For Contact Number you can use this code, first add JavaScript and call it onkeypress.
- <script type="text/javascript">
- function isNumberKey(evt)
- {
- var charCode = (evt.which) ? evt.which : event.keyCode
- if(charCode > 31 && (charCode < 48 || charCode > 57)) return false;
- return true;
- }
- </script>
- <asp:Label>Contact No.</Label>
- <asp:TextBox ID="txtClientContact" autocomplete="off" runat="server" onkeypress="return isNumberKey(event)" pattern="\+?\d[\d -]{4,9}\d">
- </asp:TextBox>
For Integers values you can use following,first add JavaScript and call on keypress.
- <script language="Javascript" type="text/javascript">
- function onlyNos(e, t)
- {
- try
- {
- if(window.event)
- {
- var charCode = window.event.keyCode;
- }
- else if(e)
- {
- var charCode = e.which;
- }
- else
- {
- return true;
- }
- if(charCode > 31 && (charCode < 48 || charCode > 57))
- {
- if(charCode === 46) return true;
- else return false;
- }
- return true;
- }
- catch(err)
- {
- alert(err.Description);
- }
- }
- </script>
- <asp:TextBox ID="txtAmount" autocomplete="off" runat="server" pattern="^[1-9][\.\d]*(,\d+)?$" onkeypress="return onlyNos(event,this);"></asp:TextBox>
For Email verification you can add pattern in TextBox,
- <asp:TextBox ID="txtClientEmail" autocomplete="off" placeholder="Enter Valid Email Id" runat="server" pattern="^\w+([-+.']\w+)*@\w+([-.]\w+)*\.[a-zA-Z]{2,3}$"></asp:TextBox>