我对文本框验证有疑问 [英] I have question about the textbox Validation

查看:65
本文介绍了我对文本框验证有疑问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有Textbox-A和Textbox-B。 Textbox-A是必填项。



如果用户通过Tab键或移动光标移动到下一个可用控件(Textbox-B)而没有输入任何内容,<> br />


应该显示错误信息。



你们中的任何人都可以通过告诉你哪个事件来帮助我写下验证。







期待尽快收到你的来信。

I have Textbox-A and Textbox-B. Textbox-A is mandatory.

If a user comes to Textbox-A and without entering anything if he moves to next available control (Textbox-B) either by tabbing or by moving the cursor,

error message should be displayed.

Could anyone of you please help me by telling in which event to write the validation.



Looking forward to hear from you ASAP.

推荐答案

试试这个!!

Try this!!
<!DOCTYPE html>
<html>
<head>
<script>
function myFunction(obj)
{

if(obj.value=="")
{
alert("Please enter Value");
}
else{
obj.value=obj.value.toUpperCase();
}
}
</script>
</head>
<body>

Enter your name 1: <input type="text" id="fname1" onblur="myFunction(this)"></br>
Enter your name 2: <input type="text" id="fname2" onblur="myFunction(this)"></br>
Enter your name 3: <input type="text" id="fname3" onblur="myFunction(this)"></br>
<p>When you leave the input field, a function is triggered which transforms the input text to upper case.</p>

</body>
</html>


<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                <asp:TextBox ID="TextBox2" runat="server" AutoPostBack="True"

                    ontextchanged="TextBox2_TextChanged"></asp:TextBox>













protected void TextBox2_TextChanged(object sender, EventArgs e)
   {
       if (TextBox1.Text == "")
       {
           Response.Write("enter value in textbox1!");
           TextBox2.Text = "";
       }
       else
       {
       }
   }


您好b $ b如果您使用的是asp.net网络应用程序,那么您应该使用



OnBlur事件当用户失去控制焦点时我们需要编写javascript验证以检查textbox1是否为emepty。

如果您需要代码,请告诉我





如果你正在使用Window应用程序,那么在Textbox控件中我们有LostFocus事件
Hi If you are using asp.net web application then you should use

OnBlur event when user lose control focus we need to write javascript validation to check whether textbox1 is emepty or not.
If you need code let me know


If you are using Window application then in Textbox control we have event of LostFocus


这篇关于我对文本框验证有疑问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆