[Javascript] Event "Handlers" (Literally)

Flavio Gomes flavio at economisa.com.br
Thu May 27 09:39:27 CDT 2004


  Let me show you what I really have got, maybe you guys have got a 
better solution.

  I got a simple form with no "submit button" that I want to be submited 
when the user changes it and leaves (onchange event) or when the user 
hits return (actual onsubmit), but I need to validate what the user 
entered: it must be and integer greater than zero and lower than a 
certain number that I obtain from PHP, let's say 8 for example.
  On the onsubmit event I return false to any non valid entries, but if 
I do the same on the onchange, It wont stop the submission.
  The solution I found was to create two separate functions, that seems 
to work, but I simply think it's not object oriented and will bring 
problems to maintenance.

Any better ideas?

---
Flavio Gomes
flavio at economisa.com.br



Gee, David wrote:

>Why wouldn't you just wrap the event handler into a function?
>
>
> form.onsubmit = myFunc;
> input.onchange = myFunc;
>
> function myFunc(e) {
> if(window.event) {e=window.event}
> ...
> }
>
>david
>
>-----Original Message-----
>From: Flavio Gomes [mailto:flavio at economisa.com.br] 
>Sent: Thursday, May 27, 2004 10:00 AM
>To: [JavaScript List]
>Subject: [Javascript] Event "Handlers" (Literally)
>
>
>Hello Everyone,
>
>  I searched for "event handler" hoping to find something actually would
>
>allow me to handle when the event occurs, but what I found was what to 
>do when the event occurs.. like onclick="alert('Oh!! I was clicked')".
>  And I wanted to do was something like this:
>    <input type=text onchange="this.form.onSubmit();">
>
>  I want to call an "event handler" on another "event handler", does 
>anybody know how to?
>
>Ps.: The above solution form.onSubmit didn't actually worked..
>
>Thanks in Advance,
>
>---
>Flavio Gomes
>flavio at economisa.com.br
>
>_______________________________________________
>Javascript mailing list
>Javascript at LaTech.edu
>https://lists.LaTech.edu/mailman/listinfo/javascript
>_______________________________________________
>Javascript mailing list
>Javascript at LaTech.edu
>https://lists.LaTech.edu/mailman/listinfo/javascript
>  
>



More information about the Javascript mailing list