Now i try to use function "onblur" with the javacript in the input text.
The alert message check is work .
But how to clear input text when the ID Card is wrong (make it empty value after alert "Wrong ID Card")
And also keep value when the ID Card is correct.
Can anyone help me. Thank you so much.
This is my Code
function checkID(id)
{
if(id.length != 13) return false;
for(i=0, sum=0; i < 12; i++)
sum += parseFloat(id.charAt(i))*(13-i); if((11-sum%11)%10!=parseFloat(id.charAt(12)))
return false; return true;}
function checkForm()
{ if(!checkID(document.idform.idcard.value))
alert('Wrong ID Card');
document.idform.idcard.value = "";
}
<form name="idform">
ID Card Check: <input type="text" name="idcard" maxlength="13" onblur="checkForm();" />
</form>
<br>
<p>(Correct ID Card = 1100701342240 ) </p>