Hi. I have made one login form and i want that if the user doesn't enter user name or password then the cursor should directly set to the empty field. How to do it? I have checked for blank field but i am not able to set focus. Please tell me how to do it? Thanks in advance.
This sends the cursor to the field that was not complete and turns the field pink. if (document.yourform.fieldname.value == "") { alert("You have not filledin this field."); document.yourform.fieldname.focus(); if(document.all || document.getElementByID){ document.yourform.fieldname.style.background = "pink"; } return false; } Code (markup):