javascript - Fix focus on input field -
There is no way to focus on the input field, say, the user enters 4 letters? Because of this, I need this because I do not have the background of my text area (stylistic purpose) and if the user clicks on a random place on my page then many users will find it difficult to find text area.
Here is my text field and button
& lt; Div id = "inputtext" & gt; & Lt; Input type = "article" id = "dream" "autofocus /> input type =" submit "id =" next post button "value =" next step "onclick =" window.open ('step3.html ',' _self ',' resizable = yes') "/> I already have some scripts running the button which hides the button And some div changes when text fields contain at least 4 characters. It would be great if I can also implement a permanent focus on this script.
$ (function ( ) {$ ("# nextstepbutton") Hide (); $ ("# dreamtext") .keyup (function () {var val = $ (this) .val (); if (val.length> 3) {$ ('# nextstepbutton'). Show (); document.getElementById ("message") .HTMLHTML = "& lt; h1> Press the 'Enter' key or next step & lt; / h1 & gt;";} and {$ ('# next post button') Hide (); document.getElementById ("message" ). InnerHTML = "& lt; h1> type please & lt; / h1>";}}})}} thanks
use blur () , focus () ... $ ('# dreamtext') ('Blurred', function () {if (this.value.length & lt; 4) this.focus ();});
Comments
Post a Comment