Link to home
Start Free TrialLog in
Avatar of WestCoast_BC
WestCoast_BCFlag for Canada

asked on

Why is my form being submitted differently when I use the mouse instead of the keyboard

I have a coldfusion page with a form on it. If I click on a field, use the backspace key to delete the current value, and then enter a new value the form works correctly. If I use the mouse to highlight the data in a field then when I release the mouse the code does not work correctly, it goes to the file defined in the action. When it work correctly the action file is called without refreshing the screen. I have not been able to create a sample page that demonstrates this. A simple example of my form is:

      <form method="post" id="frmUpdateIssue" name="frmUpdateIssue" action="d7a.cfm">
            <input type="hidden" name="iIssueID" value="23">
            <input type="text" name="testVar" onfocusout="ClickEvent()" value="7" />
      </form>
      
      <script type="text/javascript">
            function ClickEvent ()
            {
                  jQuery("#frmUpdateIssue").submit();
            }
      </script>

I understand that when I release the mouse button that the ClickEvent function should be called. What I don't understand is that when I highlight the value using the mouse and then release the mouse that the line:

jQuery("#frmUpdateIssue").submit();

behaves differently (page is redirected to d7a.cfm) than when I use the backspace key to delete the value and then type in a new value. In this case the ClickEvent function is called and the form is submitted without a redirect to a new page or screen refresh
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

https://jsfiddle.net/mplungjan/23om05gw/


There are situations where the form is submitted without the submit handler executes.

1: using the native submit

2. an error


Do you have any console messages?

Avatar of WestCoast_BC

ASKER

I don't have any console messages

First of all, you ask why is form submitted when my code does the submit()?

Second, the release of mouse has no effects to loosing focus in a field.


You have more event handlers then this one  onfocusout


You have some AJAX thingy on the page that you disturbe with the unneccessary submit()


Go to that page and copy all page source and put into a file and attach that file here.

Remove company names and passwords from the source.



To see the Developer Console press F12 in the browser.

Open the Console tab and make a screenshot and paste that image also here.


I am no longer able to reproduce this bug on my site

This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.