how to make javascript validation onsubmit go first before onclick submit button

<form name="daftar" method="post" action="daftar.php" onsubmit="return checkscript()">

<input type="submit" name="Daftar" value="Daftar" id="submit" onClick="return tq()"/>

and my js:

function checkscript() {
if (document.daftar.terms.checked == false)
{ alert('Sila pastikan anda telah check ruangan persetujuan, untuk menandakan anda setuju dengan syarat-syarat kami.');
daftar.terms.focus();
return false ;
}
else return true;
}

function tq()
{
alert("Terima Kasih!");
}
<form name="daftar" method="post" action="daftar.php" onsubmit="return tq()">

<input type="submit" name="Daftar" value="Daftar" id="submit" onClick="return checkscript()"/>

perhaps

tq..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.