function valid() { begin_checked = false; end_checked = false; alert('begin_checked: ' +begin_checked); alert('end_checked: ' +end_checked); if (document.dd.begin.checked.length == undefined || document.dd.end.checked.length == undefined ) { alert('In undefined'); } alert('end'); }
When the if statement is false, it never gets to alert(‘end’) ? When it is true, it executes properly. Why?
There is probably a null pointer exception and you do not have errors outputting to your browser.
You need some output to check:
If you get undefined from any of those, then your code will not execute properly.
Edit: Also, the other answers here all have good information. Read those as well.
Edit2: Alternative – Surround your code in a try/catch block and alert the error: