sorry im noob on JS i need help i want to try make a textbox checker that can be check the value of the textbox. when it has a value higher than 0 then has a value = 1, but when it has null value or 0 value then it has a value = 0
this my code
// JavaScript Document
function check()
{
if (document.getElementById('s1').value=="0"
|| document.getElementById('s1').value==undefined)
{
return 0;
document.getElementById('avr').value = result;
}
return 1;
document.getElementById('avr').value = result;
}
.valuewill be a string. If the field is empty it will be"", notnullorundefined.returnstatement exits the function immediately, so the...('avr').value = resultlines in your code can never be executed. Also, if those lines were before thereturnstatements you'd still have a problem becauseresultis not defined (at least, not in the code shown).