Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 更改选项卡后如何清除/删除onblur事件中的值_Html_Jquery - Fatal编程技术网

Html 更改选项卡后如何清除/删除onblur事件中的值

Html 更改选项卡后如何清除/删除onblur事件中的值,html,jquery,Html,Jquery,我的问题是,在我的注册表单中,当出现错误消息时,用户尝试更改选项卡并再次返回以注册错误消息仍然存在。当我更改选项卡并再次单击注册链接时,我应该如何才能删除错误消息 <script src="http://code.jquery.com/jquery-1.8.1.js"></script> <script> $(function() { var tabContainers = $('secti

我的问题是,在我的注册表单中,当出现错误消息时,用户尝试更改选项卡并再次返回以注册错误消息仍然存在。当我更改选项卡并再次单击注册链接时,我应该如何才能删除错误消息

<script src="http://code.jquery.com/jquery-1.8.1.js"></script>
    <script>
        $(function() {           
            var tabContainers = $('section.tabs > article');
            tabContainers.hide().filter('#login').show();

            $('.ultabs a').click(function () {
                tabContainers.hide();
                tabContainers.filter(this.hash).show();
                $('.ultabs a').removeClass('selected');
                $(this).addClass('selected');
                return false;
            });
        });
        function check_email() {
            var email=$("#textEmail").val();
            $.ajax(
            {
                type:"POST",
                url:"register.php",
                data: { 
                'email': email
                },
                success:function(msg) {
                    $("#checkEmail").html(msg);
                }
            });
            return false;
        }
        function check_password() {
            var pass=$("#textPassword").val();
            $.ajax(
            {
                type:"POST",
                url:"register.php",
                data: { 
                'pass': pass
                },
                success:function(msg) {
                    $("#checkPassword").html(msg);
                }
            });
            return false;
        }
    </script>

<nav id="siteNav">
    <h1>Navigation</h1>
    <ul class="ultabs">
        <li><a href="#login">Login</a></li>
        <li><a href="#register">Register</a></li>
    </ul>
</nav>
<section id="siteContent" class="tabs">
    <h1>Section</h1>
    <article id="login">
        <h1>Login</h1>
        <table>
            <tr>
                <td class="message" colspan="2"></td>
            </tr>
            <tr>
                <td>E-mail:</td><td><input type="email"></td>
            </tr>
            <tr>
                <td class="message" colspan="2"></td>
            </tr>
            <tr>
                <td>Password:</td><td><input type="password"></td>
            </tr>
            <tr>
                <td colspan="2"><input type="button"></td>
            </tr>
        </table>
    </article>
    <article id="register">
        <h1>Register</h1>
        <table>
            <tr>
                <td class="message" colspan="2"></td>
            </tr>   
            <tr>
                <td>Name:</td><td><input type="text"></td>
            </tr>
            <tr>
                <td id="checkEmail" class="message" colspan="2"></td>
            </tr>
            <tr>
                <td>E-mail:</td><td><input id="textEmail" type="email" onblur="return check_email()"></td>
            </tr>
            <tr>
                <td id="checkPassword" class="message" colspan="2"></td>
            </tr>
            <tr>
                <td>Password:</td><td><input id="textPassword" type="password" onblur="return check_password()"></td>
            </tr>
            <tr>
                <td class="message" colspan="2"></td>
            </tr>
            <tr>
                <td>Re-type:</td><td><input type="password"></td>
            </tr>
            <tr>
                <td colspan="2"><input type="button"></td>
            </tr>
        </table>
    </article>
</section>

$(函数(){
var tabContainers=$('section.tabs>article');
tabContainers.hide().filter('#login').show();
$('.a')。单击(函数(){
tabContainers.hide();
tabContainers.filter(this.hash.show();
$('.ultabs a').removeClass('selected');
$(this.addClass('selected');
返回false;
});
});
功能检查_电子邮件(){
var email=$(“#textmail”).val();
$.ajax(
{
类型:“POST”,
url:“register.php”,
数据:{
“电子邮件”:电子邮件
},
成功:功能(msg){
$(“#checkEmail”).html(msg);
}
});
返回false;
}
函数检查_密码(){
var pass=$(“#textPassword”).val();
$.ajax(
{
类型:“POST”,
url:“register.php”,
数据:{
“通过”:通过
},
成功:功能(msg){
$(“#checkPassword”).html(msg);
}
});
返回false;
}
航行
部分 登录 电邮: 密码: 登记 姓名: 电邮: 密码: 重新类型:
我建议您使用Basistance-提供的验证插件。它将处理错误消息,而无需您深入验证的细节。

您可以在更改选项卡时清除
td

$('.ultabs a').click(function () {
   $('.message').html('');
   // the rest of your code
});

添加错误消息的代码在哪里?包含class=“message”的td