when i create single text box on page and press enter the page refresh ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dhirajpriya
    New Member
    • Nov 2006
    • 5

    when i create single text box on page and press enter the page refresh ?

    hi everyone

    when i create single text box on page and press enter the page refresh how can i stop to refresh the page....

    dhiraj
  • dswethar
    New Member
    • Nov 2006
    • 65

    #2
    Hi,

    What is the value of your ACTION in the form tag?

    Comment

    • ronverdonk
      Recognized Expert Specialist
      • Jul 2006
      • 4259

      #3
      Make a JavaScript routine that captures (onkeypress) the ENTER keystroke and ignores it.

      Ronald :cool:

      Comment

      • AricC
        Recognized Expert Top Contributor
        • Oct 2006
        • 1885

        #4
        You are probably submitting your form if you have <input type="submit" value="submit" /> change it to <input type="button" ....

        Comment

        • dhirajpriya
          New Member
          • Nov 2006
          • 5

          #5
          Originally posted by dswethar
          Hi,

          What is the value of your ACTION in the form tag?
          i send u a simple code when u run this and press enter in the text box it refresh the page,i want to stop this refresh action.

          <HTML>
          <HEAD>

          </HEAD>

          <BODY>
          <form name="searching ">
          <input type="text" id="abc" >
          </form>
          </BODY>
          </HTML>

          Comment

          • dhirajpriya
            New Member
            • Nov 2006
            • 5

            #6
            i send u a simple code when u run this and press enter in the text box it refresh the page,i want to stop this refresh action.

            <HTML>
            <HEAD>

            </HEAD>

            <BODY>
            <form name="searching ">
            <input type="text" id="abc" >
            </form>
            </BODY>
            </HTML>

            Comment

            • dhirajpriya
              New Member
              • Nov 2006
              • 5

              #7
              Originally posted by dswethar
              Hi,

              What is the value of your ACTION in the form tag?
              i send u a simple code when u run this and press enter in the text box it refresh the page,i want to stop this refresh action.

              File Name :test.jsp
              inside test.jsp
              <HTML>
              <HEAD>

              </HEAD>

              <BODY>
              <form name="searching ">
              <input type="text" id="abc" >
              </form>
              </BODY>
              </HTML>
              Run this file on Apache Tomcat (web server)

              Comment

              • AricC
                Recognized Expert Top Contributor
                • Oct 2006
                • 1885

                #8
                Whats with the triple posting?

                Comment

                • dhirajpriya
                  New Member
                  • Nov 2006
                  • 5

                  #9
                  Originally posted by AricC
                  Whats with the triple posting?
                  sorry for triple posting my page generate error due to that it .......i think that it cannot posted so i submit three times...

                  Comment

                  • AricC
                    Recognized Expert Top Contributor
                    • Oct 2006
                    • 1885

                    #10
                    I don't see anything in your code that would make it behave that way????

                    Comment

                    • hephaestus
                      New Member
                      • Jul 2008
                      • 1

                      #11
                      From http://www.w3.org/MarkUp/html-spec/html-spec_8.html#SEC 8.2 under "Form Submission":

                      "When there is only one single-line text input field in a form, the user agent should accept Enter in that field as a request to submit the form."

                      I found out about this when I found the page http://niwo.mnsys.org/saved/~flavell/www/formquestion.ht ml

                      Comment

                      • acoder
                        Recognized Expert MVP
                        • Nov 2006
                        • 16032

                        #12
                        Welcome to the site and thanks for the information.

                        To avoid this, capture the enter key press using JavaScript and disable the action with return false as ronverdonk mentioned many months ago.

                        Comment

                        Working...