Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to prevent the paste option

Status
Not open for further replies.

pichi

Programmer
Nov 12, 2000
156
EC
hi everybody, i have a form with validate functions... when i use the keyboard the validate fs work perfect, but if i use my mouse to paste some data in that text box the fs function doesn´t work... maybe i am putting the validate in the work event... or i have to use another function...
can anybody help me...
thanks in advance

Pichi
 
You're probably using a "key" event on a textbox. Try firing your validation "onsubmit" on the form instead of "onkeyup" / "onkeydown" / "onkeypress" of individual text fields.

Of course, this assumes you don't want validation to happen "on-the-fly". If you do, the best you might get is to harness the "onblur" or "onchange" events of each field.

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
I think you should validate the form once it's submitted, but if you really want to change the pasting behavior of the browser IE supports the onbeforepaste and onpaste events which you could use to validate the clipboard contents before it gets inserted. I would guess that Firefox probably handles events similar to this as well.

Adam
 
Yes,
I used the onmousemove event of the form... with the isNaN(field), so i erase it if the value is not a number..
and the field onkeydown and onmouseout events...
although i didn't test it a 100%... thats something that i will do... fortunately i can wait a couple of days to put that validation on production...
 
thanks for your sugestions...

Pichi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top