Re: field value AFTER numeric validation

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • SAM

    Re: field value AFTER numeric validation

    Evertjan. a écrit :
    >
    Try, IE7 & FF2 tested:
    Not working on my Mac :-(
    (FF2, Safari2)

    keys with keyCode 48 to 57 need the shiftkey in addition to get a number
    from alpha keyboard
    - works with Safari
    - not with F2 who return a keyCode for the shift's key
    (not in the allowed plage :-( )

    keys from numeric keyboard aren't more allowed ... ! :-(

    But I can tape : @ & $ €

    And no more backspace ... tab ... enter ... :-(
    <input type="text" onkeypress="ret urn IsNumeric(event );">
    >
    <script type='text/javascript'>
    function IsNumeric(e) {
    var c = e.keyCode? e.keyCode : e.charCode
    if (c >= 48 && c <= 57)
    return true;
    alert('Only Numbers, please.');
    return false;
    };
    </script>
    >
    This will not prevent pasting alpha strings!!!!!
    Only if you use menu (and not use keyboard shortcuts)

    --
    sm
  • Evertjan.

    #2
    Re: field value AFTER numeric validation

    SAM wrote on 31 mei 2008 in comp.lang.javas cript:
    Evertjan. a écrit :
    >>
    >Try, IE7 & FF2 tested:
    >
    Not working on my Mac :-(
    (FF2, Safari2)
    >
    keys with keyCode 48 to 57 need the shiftkey in addition to get a
    number
    from alpha keyboard
    - works with Safari
    - not with F2 who return a keyCode for the shift's key
    (not in the allowed plage :-( )
    >
    keys from numeric keyboard aren't more allowed ... ! :-(
    >
    But I can tape : @ & $ €
    >
    And no more backspace ... tab ... enter ... :-(
    >
    ><input type="text" onkeypress="ret urn IsNumeric(event );">
    >>
    ><script type='text/javascript'>
    >function IsNumeric(e) {
    > var c = e.keyCode? e.keyCode : e.charCode
    > if (c >= 48 && c <= 57)
    > return true;
    > alert('Only Numbers, please.');
    > return false;
    >};
    ></script>
    >>
    >This will not prevent pasting alpha strings!!!!!
    >
    Only if you use menu (and not use keyboard shortcuts)
    It is a bad idea anyway, as it interferes with typing habits.

    Better test the string onsubmit.

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)

    Comment

    Working...