I am using tooltipser to put style on my website, but I tried this code to check if the textbox is empty but it did not work. can anyone help me?
HTML FORM
<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>
Remove
return(false);, it's causing the function to end after successfully initializing tooltipster in the first if: https://jsfiddle.net/LyaevuLn/2/