views:

432

answers:

3

Hi all!

In my project I need to validate the form while using entered data to enable submit button only after the correct data have been entered. I hook onkeypressed, onclick, onblur and onchange events for input field, but none of that is fired when user pastes values using mouse into the field. Currently I use setInterval to periodically check form data, but I don't like this decision. Any other ways to decide it?

Just to reiterate: I need enable submit button when correct data have been entered in input field (anyway: keyboard or mouse).

+1  A: 

No, there is no other way.

There is no cross-browser supported event to detect changes that were made with the mouse copy/paste function.

Stay with your polling approach.

Developer Art
+1  A: 

let the user submit the form, and validate then again on client side. If the validation does not pass, show some errormessages and do nothing.

If the validation does pass, submit the form to the server. But make sure to validate again on the server!

here's an example for validating before you submit the form:

http://www.htmlcodetutorial.com/forms/%5FFORM%5FonSubmit.html

Natrium
+2  A: 

You may want to have a look at the answers of a relevant question:

http://stackoverflow.com/questions/441631/how-to-detect-right-mouse-click-paste-using-javascript

Anax