brendoop Posted June 9, 2015 Share Posted June 9, 2015 //Hi , As I because my function is not working. I want you to press Enter, Caret back pro start <p>What is your name?</p> <textarea id=myText onkeypress="Enter(event)"></textarea> <script> function Enter(event) { var x = document.getElementById("myText").value; b = document.getElementById("myText"); if ((x=="Brendo") && (event.keyCode==13)) { document.getElementById("myText").value=""; b.focus(); b.setSelectionRange (0,0); } Link to comment Share on other sites More sharing options...
dsonesuk Posted June 9, 2015 Share Posted June 9, 2015 The trouble is when a user hits Enter, it is the same as submitting the form it reloads the page, it won't get a chance to focus on 'myText' element Link to comment Share on other sites More sharing options...
brendoop Posted June 9, 2015 Author Share Posted June 9, 2015 The trouble is when a user hits Enter, it is the same as submitting the form it reloads the page, it won't get a chance to focus on 'myText' element The understood , thanks Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now