如何在按TAB键后验证TextBox [英] How To Validate TextBox after Pressing TAB Key
问题描述
嗨
i想要验证用户是否在文本框中输入了某些内容,因为他按下TAB键时显示为
如果文本框为空并按TAB键则我希望验证在javascript中无法清空和事件为aslostFocus在ASP.net中
plz help
尝试
< script type = text / javascript >
函数验证(c)
{
if(c .value ==)
{
alert(必填字段不能留空);
c.focus();
}
}
< / script >
< asp:TextBox ID = TextBox1 runat = 服务器 onblur = 验证(此) > ; < / asp:TextBox > ;
尝试标签
键..
< html xmlns = http://www.w3 .org / 1999 / xhtml >
< head runat = server >
< script src = jquery-1.10.2.js type = text / javasc ript > < / script >
< 脚本 类型 = text / javascript >
函数验证(e ,txt){
var KeyID = e.keyCode;
if(KeyID == 9){
if(txt.value =='')
alert('请输入字段..');
txt.focus();
返回false;
}
}
< / script >
< / head >
< body >
< 表单 id = < span class =code-keyword> frm runat = server >
< asp:TextBox ID = txtbox onkeydown = return validate(event,this); runat = 服务器 > < / asp:TextBox >
< asp:TextBox ID = TextBox1 runat = server > < / asp:TextBox >
< / form >
< / body >
< / html > 跨度>
hi
i want to make validation whether user has entered something or not in textbox as sooon as he presses TAB key
if the textbox is blank and presses TAB key then i want validation in javascript that can not empty and event as onlostFocus in ASP.net
plz help
try
<script type="text/javascript"> function validate(c) { if(c.value=="") { alert("The required field cannot left blank"); c.focus(); } } </script> <asp:TextBox ID="TextBox1" runat="server" onblur="validate(this)"></asp:TextBox>
try this fortab
key..
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <script src="jquery-1.10.2.js" type="text/javascript"></script> <script type="text/javascript"> function validate(e, txt) { var KeyID = e.keyCode; if (KeyID == 9) { if (txt.value == '') alert('Please enter the field..'); txt.focus(); return false; } } </script> </head> <body> <form id="frm" runat="server"> <asp:TextBox ID="txtbox" onkeydown="return validate(event,this);" runat="server"></asp:TextBox> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> </form> </body> </html>
这篇关于如何在按TAB键后验证TextBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!