Codes
charCode > 31 --> allow backspace to work
charCode > 32 --> allow space to work
charCode < 97 || charCode >122 --> allow only alphabetic value
charCode < 45 || charCode > 45 --> allow only - as special character
charCode < 65 || charCode > 93 --> allow capslock character
charCode < 65 || charCode > 90 --> allow only . as special character
charCode < 48 || charCode > 57 --> allow numeric
/*For alpha and numeric*/
<script type="text/javascript">
function functionN1(evt) {
if (evt.charCode > 32 && (evt.charCode < 48 || evt.charCode > 57) && (evt.charCode < 97 || evt.charCode > 122) && (evt.charCode < 65 || evt.charCode > 93)) {
return false;
}
}
</script>
<asp:TextBox ID="txtcname" runat="server" onkeypress="return functionc(event)></asp:TextBox>
/*For numeric*/
<script type="text/javascript">
function functionx(evt) {
if (evt.charCode > 31 && (evt.charCode < 48 || evt.charCode > 57)) {
return false;
}
}
</script>
<asp:TextBox ID="txtcname" runat="server" onkeypress="return functionx(event)></asp:TextBox>
/*for alphabets*/
function functionN1(evt) {
if (evt.charCode > 32 && (evt.charCode < 97 || evt.charCode > 122) && (evt.charCode < 65 || evt.charCode > 93)) {
return false;
}
}
</script>
<asp:TextBox ID="txtcname" runat="server" onkeypress="return functionc(event)></asp:TextBox>
charCode > 31 --> allow backspace to work
charCode > 32 --> allow space to work
charCode < 97 || charCode >122 --> allow only alphabetic value
charCode < 45 || charCode > 45 --> allow only - as special character
charCode < 65 || charCode > 93 --> allow capslock character
charCode < 65 || charCode > 90 --> allow only . as special character
charCode < 48 || charCode > 57 --> allow numeric
/*For alpha and numeric*/
<script type="text/javascript">
function functionN1(evt) {
if (evt.charCode > 32 && (evt.charCode < 48 || evt.charCode > 57) && (evt.charCode < 97 || evt.charCode > 122) && (evt.charCode < 65 || evt.charCode > 93)) {
return false;
}
}
</script>
<asp:TextBox ID="txtcname" runat="server" onkeypress="return functionc(event)></asp:TextBox>
/*For numeric*/
<script type="text/javascript">
function functionx(evt) {
if (evt.charCode > 31 && (evt.charCode < 48 || evt.charCode > 57)) {
return false;
}
}
</script>
<asp:TextBox ID="txtcname" runat="server" onkeypress="return functionx(event)></asp:TextBox>
/*for alphabets*/
function functionN1(evt) {
if (evt.charCode > 32 && (evt.charCode < 97 || evt.charCode > 122) && (evt.charCode < 65 || evt.charCode > 93)) {
return false;
}
}
</script>
<asp:TextBox ID="txtcname" runat="server" onkeypress="return functionc(event)></asp:TextBox>

