troubleshooting Question

Trying to set initial focus() to a field so users can just start typing in a form --

Avatar of Phonebuff
PhonebuffFlag for United States of America asked on
Web DevelopmentJavaScriptWordPress
6 Comments1 Solution11 ViewsLast Modified:
I have a Web form built in Gravity Forms that is working quite well, But the users would like me to force Focus into the first field on the form when the form opens.  I thought I could do this with a javascript function but it does not seem to work .. I know I am missing something just not sure what -  Hopefully someone will see the error of my ways (code) and can point me in the right direction.. The function on keypress works the function to set the focus initially does not.  Looking at the .ready documentation, but not sure that is the way I need to go.

[code]
<script type="text/javascript">
    jquery(function($){
      $('input[name=Badge]').focus();
    });
    jQuery(function($){
        $("form").keypress(function(e) {
            //Enter key
            if (e.which == 13) {
                return false;
            }
        });
    });      
    </script>
[/code]



ASKER CERTIFIED SOLUTION
Zvonko
Systems architect

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Top Expert 2006

The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.

Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros