473,382 Members | 1,545 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

events get lost (from onBlur to onClick)

Hi

Hope somebody knows how to solve this one.

*The Situation*
A traditional situation where HTML form inputs are checked...

(if simplified then it would look something like this)

<form onSubmit="return checkWholeForm(this)">
<!-- other inputs -->
<input type="text" name="anInput" onBlur="dataCheck(this, ...)" />
<span id="error_anInput"></span>
<!-- other inputs -->
<input type="submit" name="btnSubmit" />
</form>

dataCheck validates the inputs value and if something is wrong, then..
document.getElementById('error_anInput').innerHTML = 'Error!'
or if data is valid then the content of span is removed.

The checkWholeForm function iterates through all elements on the form
and triggers onblur() for each input... leading to executing function
dataCheck (and so changing innerHTML of some specific span elements if
needed).

*The Problem*
If I have entered incorrect data to an input and hit the submit button
with my mouse (causing the onBlur event to be triggered just right
before onSubmit) then *occasionally* for some fields the onSubmit event
is not triggered because the onClick event is not triggered. :S

As there are actually quite many complex functions (tested and these
seem OK afaik) that are doing the checks then dowes anyboudy have a clue
what type of code might break this. I thought at first that setting
innerHTML to some value during onBlur disables all waiting events but as
this is happening occasionally (on some machines) I'm in doubt...

any ideas what to check? double declaration of function/variable names?
Not deleting some object after usage? ... anything?

Waiting for any ideas...

PS. http://eix.lap.ee/test/portali_js.html in the example *occasionally*
third field generates the error - remove any content from the field
and stright hit the submit (*with mouse* - to create onBlur and onClick
at the same time).

Thanks for any ideas...

Heiko
Oct 5 '05 #1
2 5646
I would suggest avoiding using `submit` buttons altogether. If you have
JavaScript and all users must use JavaScript then set the onsubmit
event of the form to `return false`.

Create a regular non submit / image / ... with an onclick event that
fires a function. This function should do all the processing you need
and if everything checks out ok then execute
document.forms["~FormName~"].submit().

This probably will get around your issues with events.

As a side note, I would also suggest not firing onblur events to
validate your form fields. The way that I develop is that I have a data
structure (recordset of sorts) that stores all validation entries for
the page keeping the form elem names, the alias's (for alerts), and the
types of validations requred (Null, Null Warning, Date, Integer,
Percent, ...). When the onblur of the form fires it calls a function
that searches out the validation entries in the data structure. When
the form is submitted, it loops through entire data structure and runs
same validations (without executing onblur).

This method has been in my production env for 4 years now and still
running strong. I even keep a spreadsheet to store my form attributes
and the various validations requred and the spreadsheet generates the
JavaScript for me. I just copy and paste into the template.

JsD

Oct 6 '05 #2
> PS. http://eix.lap.ee/test/portali_js.html in the example *occasionally*
third field generates the error - remove any content from the field and
stright hit the submit (*with mouse* - to create onBlur and onClick at
the same time).


Javascript events... i figured it out but how could I solve it...
The thing is that occasions were these where the submit button at the
end of the page moved. Changing innerHTML abouve must be big enough to
make the bottom of the page move. So when clicking on the button the
onblur moved the button while the onclick event is published on the
location where button was rendered before.

Tricki :)

Thanks for reading... I made my point so if anybody should get stuck to
the same problem... the problem is known and could be avoided...
--
Heiko
To boldly go where no one has gone before
Oct 6 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Sandman | last post by:
Below you find a small test page. I contains an input box, with an onBlur event, and a form, with an onSubmit event. When I place the cursor in the text box and push ENTER, first the onBlur...
4
by: Gaz | last post by:
This is impossible right?? This is a very simplified description of my form so don't worry if it sounds like I could do it a different way, it's just because I have simplified it. I have two...
1
by: Christoph | last post by:
I'm trying to validate some HTML form elements when the user tabs out of each element. However, I'm having some problems. It appears that the order of events is onChange followed some time...
6
by: Thomas | last post by:
Hi, I'm having a problem with the dynamically created inputfields in Internet Explorer. The situation is the following: - I have a dynamically created table with a textbox in each Cell. - It...
1
by: Jim | last post by:
DB I'm trying to dynamically create a set of HtmlInputRadioButton radio buttons at runtime using C# that loops through a data reader. I'm able to set all of the properties and have everything...
2
by: Robert Bravery | last post by:
HI all, I have a form for searches on a mysql database/table. The form has on input text box, and several pushbuttons. Depending on which pushbutton is selected, the search is then done on a...
5
by: connectwithme | last post by:
I am trying to attach a "onblur" event on the body element. IE does'nt throw any errors but the event is not captured by the browser when the onblur occurs on the elements withing the body. But...
1
by: swethak | last post by:
Hi, I am desiging the calendar application for that purpose i used the below code. But it is for only displys calendar. And also i want to add the events to calendar. In that code displys the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.