取消隐藏或隐藏基于文本框空白的行 [英] unhide or hide row based on textbox blank or not

查看:113
本文介绍了取消隐藏或隐藏基于文本框空白的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请让我知道当文本框不为空时我如何隐藏错误消息行意味着如果我单击文本框然后我将文本框留空并移动到下一个文本框然后应该可见一行显示错误,否则它应该隐藏.. ..但我的代码不能正常工作





Please let me know how i hide error message row when textbox is not blank means if i click at textbox and then i leave textbox blank and move to next textbox then a row should be visible to show error otherwise it should hide....but my code is not working


<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<style type="text/css">
.abc
{
    display:inline
    }
</style>
<script language="javascript" type="text/javascript">
    function blank() {
        if (IsBlank('txtEmail', 'tremail') == false) {
            return false;
        }
    }
    function IsBlank(control,row) {
        if (document.getElementById(control).value == " ") {
            document.getElementById(row).style.display = '';
            document.getElementById(control).focus();
        }
        else {
            document.getElementById(row).style.display = 'none';
        }
    }
    function checkEmail() {

        var email = document.getElementById('txtEmail');
        var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

        if (!filter.test(email.value)) {
            alert('Please provide a valid email address');
            email.focus;
            return false;
        }
    }</script>
<body>
    <form id="form1" runat="server">
    <div>
            <table id="Table1" style="width: 100%" runat="server">
                <caption style="width: 100%" class="caption">Become a Member of Naukri.com and find the right job. Create your Profile now, Free!</caption>
                <tr>
                    <td align="left" colspan="2"><b>Create login Details</b></td>
                </tr>
                <tr>
                    <td align="right" style="width:43%">Enter Your Email Id<span style="color:Red">*</span>&nbsp:&nbsp</td>
                    <td >
                    <asp:TextBox ID="txtEmail" runat="server" onchange="IsBlank(this,'tdEmail');"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td align="center" colspan="2">&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
                    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
                    &nbsp&nbsp&nbsp&nbsp;Please register using your current email address.</td>
                </tr>
                <tr id="tremail">
                    <td align="center" colspan="2" id="tdEmail">&nbsp&nbsp&nbsp&nbsp
                    &nbsp&nbsp&nbsp;Please specify your email ID.</td>
                </tr>
                 <tr>
                    <td align="right" style="width:44%">Create a Password For Your Account<span style="color:Red">*</span>&nbsp:&nbsp</td>
                    <td >
                    <asp:TextBox ID="Txtpswrd" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                <td align="center" colspan="2">&nbsp&nbsp&nbsp&nbsp;&nbsp;Please specify a password.</td>
                </tr>
                 <tr>
                    <td align="right" style="width:35%">Confirm the Password<span style="color:Red">*</span>&nbsp:&nbsp</td>
                    <td >
                    <asp:TextBox ID="TxtCnfrmPswrd" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                <td align="center" colspan="2">&nbsp&nbsp&nbsp&nbsp;&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp;Please specify confirm password.</td>
                </tr>







< / form>

< / body>

< / html>




</form>
</body>
</html>

推荐答案

/;

if (!filter.test(email.value)){
alert('Please 提供 a 有效 email 地址');
电子邮件 焦点;
return false;
}
} < / script >
< body >
< 表格 id = form1 runat = server >
< div >
< id = 表1 style = width:100% runat = server >
< caption 样式 = width:100% class = 标题 > 成为Membe在Naukri.com找到合适的工作。立即创建您的个人资料,免费!< / caption > ;
< tr >
< td align = left colspan = 2 > < b > 创建登录详细信息< / b > < / td >
< / tr >
< tr >
< td < span class =code-attribute> align = right style = width:43% > 输入您的电子邮件ID < span 样式 = 颜色:红色 > * < / span > & nbsp:& nbsp < / td >
< td >
< asp:TextBox ID = txtEmail runat = server onchange = IsBlank(this,'tdEmail'); > < / asp:TextBox >
< / td >
< span class =code-keyword>< / tr >
< tr >
< td align =
center colspan = 2 > & nbsp& nbsp& ; NBSP&安培; NBSP&安培; NBSP&安培; NBSP&安培; NBSP&安培; NBSP&安培; NBSP&安培; NBSP&安培; NBSP&安培; NBSP&安培; NBSP&安培; NBSP
和NBSP&安培; NBSP&安培; NBSP&安培; NBSP&安培; NBSP&安培; NBSP&安培; NBSP&安培; NBSP&安培; NBSP&安培; NBSP&安培; NBSP&安培; NBSP&安培; NBSP&安培; NBSP&安培; NBSP&安培; NBSP
和NBSP&安培; NBSP&安培; NBSP&安培; NBSP;请注册使用当前的电子邮件地址<跨度类= 代码关键字>< < span class =code-leadattribute> / td >
< / tr >
< tr id = tremail >
< < span class =code-leadattribute> td align = center colspan = 2 id = tdEmail > & nbsp& nbsp& nbsp& nbsp
& nbsp& nbsp& nbsp;请指定您的电子邮件ID。 < / td >
< / tr >
< tr >
< td align = < span class =code-keyword> right style = width:44% > 为您创建密码帐户< span style = 颜色:红色 > * < / span > & nbsp:& nbsp < / td >
< td >
<asp:TextBox ID=\"Txtpswrd\" runat=\"< span class=\"code-keyword\">server\"></asp:TextBox>
</td>
</tr>
<tr>
<td align=\"center\" colspan=\"2\">&nbs p&nbsp&nbsp&nbsp;&nbsp;Please specify a password.</td>
</tr>
<tr>
<td align=\"right\" style=\"width:35%\">Confirm the Password<span style=\"color:Red\">*</span>&nbsp:&nbsp</td>
<td >
<asp:TextBox ID=\"TxtCnfrmPswrd\" runat=\"server\"></asp:TextBox>
</td>
</tr>
<tr>
<td align=\"center\" colspan=\"2\">&nbsp&nbsp&nbsp&nbsp;&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp;Please specify confirm password.</td>
</tr>
/; if (!filter.test(email.value)) { alert('Please provide a valid email address'); email.focus; return false; } }</script> <body> <form id="form1" runat="server"> <div> <table id="Table1" style="width: 100%" runat="server"> <caption style="width: 100%" class="caption">Become a Member of Naukri.com and find the right job. Create your Profile now, Free!</caption> <tr> <td align="left" colspan="2"><b>Create login Details</b></td> </tr> <tr> <td align="right" style="width:43%">Enter Your Email Id<span style="color:Red">*</span>&nbsp:&nbsp</td> <td > <asp:TextBox ID="txtEmail" runat="server" onchange="IsBlank(this,'tdEmail');"></asp:TextBox> </td> </tr> <tr> <td align="center" colspan="2">&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp &nbsp&nbsp&nbsp&nbsp;Please register using your current email address.</td> </tr> <tr id="tremail"> <td align="center" colspan="2" id="tdEmail">&nbsp&nbsp&nbsp&nbsp &nbsp&nbsp&nbsp;Please specify your email ID.</td> </tr> <tr> <td align="right" style="width:44%">Create a Password For Your Account<span style="color:Red">*</span>&nbsp:&nbsp</td> <td > <asp:TextBox ID="Txtpswrd" runat="server"></asp:TextBox> </td> </tr> <tr> <td align="center" colspan="2">&nbsp&nbsp&nbsp&nbsp;&nbsp;Please specify a password.</td> </tr> <tr> <td align="right" style="width:35%">Confirm the Password<span style="color:Red">*</span>&nbsp:&nbsp</td> <td > <asp:TextBox ID="TxtCnfrmPswrd" runat="server"></asp:TextBox> </td> </tr> <tr> <td align="center" colspan="2">&nbsp&nbsp&nbsp&nbsp;&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp;Please specify confirm password.</td> </tr>







</form>

</body>

</html>




</form>
</body>
</html>


Hiding the information which has been added on a previous step is a really, really bad idea. Just don’t do it.



—SA
Hiding the information which has been added on a previous step is a really, really bad idea. Just don't do it.

—SA


you can try validation of \"RegularExpressionValidator.
you can try validation of "RegularExpressionValidator.
<asp:regularexpressionvalidator id="RegularExpressionValidator2" runat="server" xmlns:asp="#unknown">
                                ControlToValidate="Control Name" ErrorMessage="RegularExpressionValidator" 
                                ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:regularexpressionvalidator>


这篇关于取消隐藏或隐藏基于文本框空白的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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