delphi programming forums mysql charset mget recursive synonimos
free ventrilo servers hosting cs javascript delay python find in list
Back Forum New
abstract:

                return true;
        else if (dec && (keychar == ".")) {
                myfield.form.elements.focus();
                return false;
        }
        else
                return false;
}
//-->
I appreciate it if you can help with this query.
Many thanks,
TD


Hi there,
I was wondering how this can be amended to also allow only a full stop from being input?
Code:
  1. <!--
  2. function numbersonly(myfield, e, dec) {
  3.         var key;
  4.         var keychar;
  5.         if (window.event)
  6.                 key = window.event.keyCode;
  7.         else if (e)
  8.                 key = e.which;
  9.         else
  10.                 return true;
  11.                 keychar = String.fromCharCode(key);
  12.         if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) )
  13.                 return true;
  14.         else if ((("0123456789").indexOf(keychar) > -1))
  15.                 return true;
  16.         else if (dec && (keychar == ".")) {
  17.                 myfield.form.elements[dec].focus();
  18.                 return false;
  19.         }
  20.         else
  21.                 return false;
  22. }
  23. //-->
Copy Code
I appreciate it if you can help with this query.
Many thanks,
TD

TOP

$newvar = parsefloat($oldvar);
IIRC, that will convert the $oldvar to a float, which will strip out chars other than "." (I think! double-check lol!!)

TOP


Originally Posted by badger_fruit
$newvar = parsefloat($oldvar);
IIRC, that will convert the $oldvar to a float, which will strip out chars other than "." (I think! double-check lol!!)
Hey thanks for your reply, but it okay i just added a . within the numbers and it allows the decimal point
Code:
  1.         else if ((("0123456789.").indexOf(keychar) > -1))
  2.                 return true;
Copy Code




                return true;
        else if (dec && (keychar == ".")) {
                myfield.form.elements.focus();
                return false;
        }
        else
                return false;
}
//-->
I appreciate it if you can help with this query.
Many thanks,
TD

TOP

Back Forum