在java脚本中验证 [英] Validation in java script
本文介绍了在java脚本中验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
function isNumberKey()
{
var key = window.event.keycode;
if (key < 48 || key > 57) {
return false;
}
else {
return true;
}
}
function IsAlpha() {
var key = window.event.keycode;
if ((key >= 65 && key <= 90) || (key >= 97 && key <= 122)) {
return true;
}
else {
return false;
}
}
<tr>
<td align="right" style="width:20%">MOBILE NO.</td>
<td class="style3"><asp:TextBox ID="TXT_M_NO" class="txt" runat="server" onkeypress="return isNumberKey()" BackColor="lightyellow"></asp:TextBox>
</td>
<td colspan="2"></td>
</tr>
<tr>
<td align="right" class="style2" style="width:20%">
<span style="color:Red;">*</span> EMPLOYEE NAME </td>
<td class="style1"><asp:TextBox ID="TXTEMP_NAME" class="txt" runat="server" onkeypress="return IsAlpha()" BackColor="lightyellow"></asp:TextBox>
</td>
<td align="right" style="width:10%">LAST NAME</td>
<td><asp:TextBox ID="TxtLnm" class="txt" runat="server" onkeypress="return IsAlpha()" BackColor="lightyellow"></asp:TextBox>
</td>
</tr>
这两个验证功能不起作用
请让我知道如何它将工作
These two function of validation is not working
please let me know how it will work
推荐答案
使用asp自定义验证器,如下所示:
ASP CustomValidator
的CustomValidator。 ClientValidationFunction属性
除客户端外,还应包括服务器端验证。
Use an asp custom validator as follows:
ASP CustomValidator
CustomValidator.ClientValidationFunction Property
Besides client side, should also include server side validation as well.
这篇关于在java脚本中验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文