Allow only numbers or decimal point input Javascript
Advertisements
* Text box only allows decimal point when entering numbers or call this method.
* Obj: the text box object
* /
function clearNoNum (obj) (
if (inNaN (obj.value)) (
obj.value = obj.value.replace (/ [^ \ d.] / g ,""); / / first replace all non-numbers, except numbers and.
obj.value = obj.value.replace (/ ^ \. / g ,"");// must ensure that digital rather than the first.
obj.value = obj.value.replace (/ \. (2,) / g ,"."); / / ensure that only the emergence of a. but no more.
/ / Guarantee. Only occurs once, and not more than twice
obj.value = obj.value.replace (".","$#$"). replace (/ \. / g ,""). replace ("$#$",".");
)
)
Related Posts of Allow only numbers or decimal point input Javascript
-
Play flash page 3 (javascript script swfobject.js1)
/ ** * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/ * * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License: * Http://www.opensource.org/licenses/mit-license.php * * / if (typeof deconc ...
-
Play flash page 3 (javascript script swfobject.js2)
this.setAttribute ( "swf", this.xiSWFPath);) _19 = "<object \" "+ this.getAttribute (" id ") +" \ "classid = \" clsid: D27CDB6E-AE6D-11cf-96B8-444553540000 \ "width = \" "+ this.getAttrib
-
Hibernate performance tuning (the focus of understanding)
1. Object Cache: fine-grained, in view of the table Record Level, transparent access, without changing the procedure code can greatly enhance the performance of web applications. ORM object cache is a magic weapon for the victory. 2. The merits of th ...
-
javascript: history.go () and History.back () the difference between collections
<input type=button value= Refresh > <input type=button value= Forward > <input type=button value= Back > <input type=button value= Forward > <input type=button value= Back > Back + refresh <input type=button value= Ba ...
-
Real design pattern
I hate the thought of the time to teach some provide a lot of code, because I think the thought process of acceptance should be a pleasure to read as a novel process, rather than spend a lot of brain power for a certain process details And this world ...
-
Detailed JS regular expressions
Opening, or have to talk about ^ and $ that they are separately used to match the beginning and end of the string, the following examples to illustrate separately "^ The": there must be at the beginning of "The" string; "of despai
-
JavaScript inheritance
About JavaScript inherited a small example ... <! DOCTYPE HTML PUBLIC "- / / W3C / / DTD HTML 4.01 / / EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" conte ...
-
JavaScript String Functions Guinness
Own JS function 1.Asc (x), Chr (x): convert characters, character code 2. Filter: Search string array of a specific string Format: v = filter (x, s [, include [, compare]]) Examples: Dim x ()={" kjwang "," wangkj "," peter ")
-
EJB ant script to deploy template works
<? xml version = "1.0" encoding = "UTF-8"?> <! - Name Project name basedir build.xml file directory -> <project name="HelloWorld" basedir="."> <! - Property variables -> <! - The sour ...
-
java read file
java read documents in two ways: java.io and java.lang.ClassLoader When using the java.io, when java.lang.ClassLoader use it? (Note: If prior to read xml file java read file clearly aware of these two methods have been like! Can take much less to understa












