[Hello, i want to check weather a text box is exisit or not using typeof. but i have some confusing on the syntax. <input name="empno" type="text" id="empno" size="15" /> Code (markup): is this syntax correct? if (typeof empno=='object') { Code (markup): because i have some confusing weather i need rap empno in single quote.
http://www.javascriptkit.com/javatutors/determinevar2.shtml Read the above page it explains everything you need. The code you have posted is correct and you do need to encase the value with quotes as the return is a string.
You can just check if it's truthy or not. var empno = document.getElementById('empno'); if (empno) { // exists } Code (markup):
no buddy, that text box (id empno) may exist some time and some time not in the form, so i want to check weather that text box is present or not.