the user cannot type letters or special characters into the input field.
could you please help me?
the user cannot type letters or special characters into the input field.
could you please help me?
Code:<input type="text" onkeyup="this.value=!this.value.match(/[\d.]$/)?this.value.substring(0,this.value.length-1):this.value;">
Learn how to code at 02geek
The more you learn, the more you'll realize there's much more to learn
Ray.ph!
for +ve and -ve floating point
Code:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title></title> </head> <script language="JavaScript" type="text/javascript"> /*<![CDATA[*/ function zxcFloat(obj){ obj.value=obj.value.replace(/[^-?\d\.]/g,''); obj.value=parseFloat(obj.value); } /*]]>*/ </script> <body> <input name="" onblur="zxcFloat(this)"/> </body> </html>
if the user press any letter/special characters, it will not appear in the textbox.
thanks
Bookmarks