Only Text Field Validations Using Javascript

Self-Innovator
Posted by Self-Innovator under JavaScript category on | Points: 40 | Views : 1662
Page Design
<table align="center">
<tr>
<td>
Employee Name
</td>
<td>
<asp:TextBox ID="txtName" Onchange="return ValidateName(this)" runat="server"></asp:TextBox>
</td>
</tr>
</table>


Javascript Function
<script type="text/javascript" language="javascript"> 
function ValidateName(x) {
var AlphExp = /^[a-zA-Z]+$/;
if (x.value.match(AlphExp))
{
return true;
}
else
{
alert("Invalid Name");
x.value = "";
x.focus();
return false;
}
}
</script>

Comments or Responses

Login to post response