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