ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> php-general
php-general
Re: [PHP] [JS question] : I want to block onChange event in Firefox...
by David BERCOT other posts by this author
Jun 30 2006 12:34AM messages near this date
Re: [PHP] [JS question] : I want to block onChange event in Firefox... | Re: [PHP] [JS question] : I want to block onChange event in Firefox...
>  Hi,
>  
>  did you try to open the javascript console in firefox to see if there is 
>  any error ?
>  (in the "tools" or "outils" menu).

Yes I did. No error...

I was told to go to a JS list (here, it is a PHP one), so I'll look for one ;-)

Thank you / merci.

David.

>  hope this'll help / bon courage
>  
>   N F
>  
>  David BERCOT a écrit :
>  > Hi,
>  >
>  > I am blocked on this problem since so a long time that I prefer asking here my question.
..
>  > I'd like, if the data isn't correct, that the user stay in the input zone. Everything is
 ok with IE but not with Firefox.
>  > Here is my code :
>  > // Validation des données.
>  > function demarrage_controles() {
>  >       if (FF) {
>  >             document.captureEvents(Event.KEYPRESS);
>  >             document.captureEvents(Event.CHANGE);
>  >             document.onkeypress = process_keypress;
>  >             document.onchange = process_change;
>  >     } else {
>  >             document.onkeypress = process_keypress;
>  >             for (i=0; i < document.forms[0].elements.length ; i++) {
>  >                   document.forms[0].elements[i].attachEvent("onchange",process_change);
>  >             }
>  >       }
>  > }
>  > // On n'accepte que des chiffres.
>  > function process_keypress(e) {
>  >       if (FF) {
>  >             if (e.target.tagName == "input" && !((e.which > 47 && e.which < 58) || e.whi
ch == 0 || e.which == 8 || e.which == 13)) {
>  >                   return false;
>  >             }
>  >       } else {
>  >             if ((window.event.keyCode < 47 || window.event.keyCode > 58) && window.event
.keyCode != 13) {
>  >                   return false;
>  >             }
>  >       }
>  > }
>  > // On compare au dernier cumul.
>  > function process_change(e) {
>  >       if (FF) {
>  >             if (e.target.id.substr(0,3) == "var" && e.target.alt != "") {
>  >                   if (Number(e.target.value) < Number(e.target.alt)) {
>  >                         alert ("Vous ne pouvez pas saisir de données inférieures au de
rnier cumul !");
>  >                         e.preventDefault();
>  >                         e.stopPropagation();
>  >                         e.returnValue=false;
>  >                   }
>  >             }
>  >       } else {
>  >             if (window.event.srcElement.id.substr(0,3) == "var" && window.event.srcEleme
nt.alt != "") {
>  >                   if (Number(window.event.srcElement.value) < Number(window.event.srcEle
ment.alt)) {
>  >                         alert ("Vous ne pouvez pas saisir de données inférieures au de
rnier cumul !");
>  >                         window.event.returnValue = false;
>  >                   }
>  >             }
>  >       }
>  > }
>  > My problem comes from the process_change function in Firefox where I put everything I kn
ow (stopPropagation etc...) but without success. The user go to the next field. In IE, the w
indow.event.returnValue = false is ok.
>  >
>  > Do you have any clue ?
>  >
>  > Thank you very much.
>  >
>  > David.
>  >
>  >   
>  
>  
>  
>  ---------------------------------------------------------------------------------------
>  Orange vous informe que cet  e-mail a ete controle par l'anti-virus mail. 
>  Aucun virus connu a ce jour par nos services n'a ete detecte.
>  
>  >
>  [ (pas de nom de fichier) (0.1 Ko) ]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Thread:
David BERCOT
Chris
David BERCOT
Nicolas Figaro

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved