skaterdav85 Posted November 6, 2008 Share Posted November 6, 2008 So im creating a form, and I have JS validation where it checks the textbox to see if it is empty or not. I want the focus to remain on the form object if the form object is left blank. Is there some kind of focus property for the form to do this in JS? or any other way i can look into in JS? Thanks! Link to comment Share on other sites More sharing options...
MinusMyThoughts Posted November 6, 2008 Share Posted November 6, 2008 I would look into the onblur and onfocus properties. You can write functions that are triggered with those events that could check the value and reset focus if necessary.-Jason Link to comment Share on other sites More sharing options...
skaterdav85 Posted November 6, 2008 Author Share Posted November 6, 2008 I would look into the onblur and onfocus properties. You can write functions that are triggered with those events that could check the value and reset focus if necessary.-Jasonya i have the onblur event, but even when my alert comes up saying "Dont leave the field empty", it still moves to the next field. How do i reset the focus? Link to comment Share on other sites More sharing options...
MinusMyThoughts Posted November 6, 2008 Share Posted November 6, 2008 Did you try document.getElementById("yourInput").focus() already?-Jason Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.