Tooltipster jQuery插件用于检查空文本框

时间:2015-10-15 13:41:17

标签: javascript jquery html jquery-tooltip

我正在使用tooltipser将样式放在我的网站上,但我尝试使用此代码来检查文本框是否为空,但它不起作用。有谁可以帮助我?

HTML表格

<form name="studentform" method="POST" action="index.php" role="form" onsubmit="return check(this)" autocomplete="off">
    <center>
        <input type="text" name="suid" class="suid" id="suid" placeholder="STUDENT NO." title="Student No. is required">
        <input type="password" name="pass"  id="pass" class="pass" placeholder="PASSWORD" title="Password is required">
        <input type="submit" name="login" class="sub" value="LOG IN">
    </center>
</form>

jQUERY(Tooltipster)

    <script>
        function check()
        {
            if (!studentform.suid.value)
            {

                $('.suid').tooltipster({
                animation: 'grow',
                delay: 200,
                theme: 'tooltipster-default',
                touchDevices: true,
                trigger: 'hover',
                position: 'right'
                });return (false);

            }
            if (!studentform.pass.value)
            {
                $('.pass').tooltipster({
                animation: 'grow',
                delay: 200,
                theme: 'tooltipster-default',
                touchDevices: true,
                trigger: 'hover',
                position: 'right'
                });
                return (false);
            }
            else {return true;}
        }
</script>

1 个答案:

答案 0 :(得分:0)

删除return(false);,导致该功能在第一个if https://jsfiddle.net/LyaevuLn/2/成功初始化工具提示后结束