# js determine whether or not a positive integer input. The function of the number of floating-point numbers, etc.

2009-10-24  来源：本站原创  分类：AJAX  人气：637

1. The following is a list of some types of numerical interpretation of regular expressions

"^ \ \ d + \$" / / non-negative integer (positive integer + 0)
"^ [0-9] * [1-9] [0-9] * \$" / / a positive integer
"^((- \ \ d +) | (0 +))\$" / / non-positive integer (negative integer + 0)
"^ - [0-9] * [1-9] [0-9] * \$" / / a negative integer
"^ -? \ \ d + \$" / / integer
"^ \ \ d + (\ \. \ \ d +)?\$" / / non-negative floating-point numbers (floating point number is + 0)
"^(([ 0-9] + \ \. [0-9] * [1-9] [0-9 ]*)|([ 0-9] * [1-9] [0-9] * \ \. [0-9 ]+)|([ 0-9] * [1-9] [0-9 ]*))\$" / / are floating point
"^((- \ \ d + (\ \. \ \ d +)?)|( 0 + (\ \ .0 +)?))\$" / / non-floating-point number is (negative float + 0)
"^(-(([ 0-9] + \ \. [0-9] * [1-9] [0-9 ]*)|([ 0-9] * [1-9] [0-9 ] * \ \. [0-9 ]+)|([ 0-9] * [1-9] [0-9 ]*)))\$" / / negative float
"^(-? \ \ d +) (\ \. \ \ d +)?\$" / / float

2. In the process the use of

var r = / ^ [0-9] * [1-9] [0-9] * \$ / / / positive integer

r.test (str); / / str for the character you want to judge the results of the implementation of return true or false

3. The test is then a function of the number of characters can be used to determine the date of the js function Email

function TestRgexp (re, s) (/ / parameters that re regular expression for s in order to determine the character

return re.test (s)

)

4. Function Application

<script type="text/javascript">

function TestRgexp (re, s) (/ / parameters that re regular expression for s in order to determine the character

return re.test (s)

)

var re = / ^ [0-9] * [1-9] [0-9] * \$ /;

/ / Determine whether it is a positive integer

/ / Note: The procedures for the regular expression format Chiang Kai-shek: / the above regular expression (without double quotes) /
var s = prompt ( "Please enter the characters to judge", 10);

var result = TestRgexp (re, s); / / test to return true or false

</ script>

• js determine whether or not a positive integer input. The function of the number of floating-point numbers, etc. 2009-10-24

1. The following is a list of some types of numerical interpretation of regular expressions "^ \ \ d + \$" / / non-negative integer (positive integer + 0) "^ [0-9] * [1-9] [0-9] * \$" / / a positive integer "^((- \ \ d +) | (0 +))\$&

• js input to determine whether or not a positive integer. Float figure such as a function of 2009-03-28

js input to determine whether or not a positive integer, floating-point numbers, such as a function of figure 1. The following is a list of some types of numerical interpretation of regular expressions "^ \ \ d + \$" / / non-negative integer (pos

• JS determine the integer 2010-12-21

//JS Determine whether an integer .. if(num.value.search("^\\d+\$") != 0){ ................ } // Whether positive or negative number if(num.value.search("^-?\\d+\$") != 0){ ................ }

• Determine a positive integer is not symmetrical 2010-09-28

Is symmetric to determine a positive integer number, can not use the library function into a string bool isSymMum(const unsigned long num) { int index = 0; long temp = num; char array; // The definition of an array Wrong wrote byte[] array = byte

• javascript to determine whether a positive integer 2008-07-09

if (value <0 | | value! = parseInt (value)) ( alert ( "not a positive integer"); ) else ( alert ( "is a positive integer"); )

• js determine some of the excerpts 2011-05-20

[/ Align] [align = center] Right to prevent <script language="JavaScript"> function helpor () { if (event.button == 2) alert ('only visit! Thank you! \ n \ n If the problem please contact me!') } </ Script> Then changed <body>

• jQuery to judge whether the number entered is a positive integer? 2010-04-26

// Enter the number of a judgment is not a positive integer jQuery(".amount").keyup(function(){ var value = jQuery(this).val(); if((/^(\+|-)?\d+\$/.test( value ))|| value<0){ return true; }else{ alert(" Please enter a positive integer num

• Positive integer decomposition 2010-09-19

Question: will be a positive integer n represented as a series of positive integers. N = n1 + n2 + n3 +...+ nk (n1> = n2> = n3> = nk> = 1, k> = 1) which is being a partition of an integer n, positive integer n the number of different classi

• Positive integer partitioning problem 2010-12-21

/ * * Positive integer partitioning problem * 6 * 5 +1 * 4 +1 +1 +2 = 4 * 3 +3 = 3 +2 +1 +1 +1 +1 = 3 * 2 +2 +2 = 2 +2 +1 +1 +1 +1 +1 +1 = 2 * 1 +1 +1 +1 +1 +1 * / # Include <stdio.h> / * * The largest positive integer n is decomposed into a combina

• JS determine the browser type (if using IE, Firefox, Opera browser) 2011-05-19

Keywords: JS determine the browser (if using IE, Firefox, Opera browser), IE core, netscape kernel Now there are about several browser, the personal preferences are different, so it is to use a different browser! We have developed for people who ofte

• js determine the character is Chinese, Chinese characters, numbers 2011-06-01

/ * Determines whether the specified content is empty, if the pop-up alert box is empty * / function isEmpty (theValue, strMsg) { if (theValue ==""){ alert (strMsg + "can not be null!"); return true; } return false; } / * Chinese judge

• Integer array for the second largest number _ array to achieve with purely 2010-09-19

Integer array for the second largest number, complete with an array to realize (of course you can do with a single list). General idea is: first, small to large order, then get the largest number, followed by the second largest number can be here tak

• js使用循环清空某个div中的input标签值 2014-02-07

清空div中input标签值的方法有很多,下面为大家介绍下使用循环清空某个div中的input标签值的具体实现 HTML页面 <div class="col-xs-9" id="search_songs_a"> <table> <tbody> <tr> <th>钢琴曲名称:</th> <td><input type="text" name="inf

• js determine whether a number is positive 2010-09-26

isNaN (variable or digital) is positive, return true otherwise return false

• js verify whether the number (positive integer, 0, negative integers, decimals) 2010-11-15

<script language="JavaScript" type="text/javascript"> function checkNum (obj) { var re = /^-?[ 1-9] * (\. \ d *)?\$|^-? 0 (\. \ d *)?\$/; if (! re.test (obj.value)) { alert ("Illegal number"); obj.value = ""; ob

• JS determine the IE6, IE7, IE8, FF 2010-10-18

Judgement JQuery browser \$. Browser.msie, EXtjs the judge to use Ext.isIE? var isIE = !!window.ActiveXObject; var isIE6 = isIE && !window.XMLHttpRequest; var isIE8 = isIE && !!document.documentMode; var isIE7 = isIE && !isIE6 &

• js determine the type of file uploaded 2010-03-09

Work is necessary to identify the file type upload pictures (gif, jpg, png) view: <% form_for :complain_evidence,:url => {:action => "upload_complain_evidence",:id => @order.seq_no},:html => {:id => 'f_e',:multipart => true}

• js determine an object type in 2010-04-18

1, typeof operator. For Function, String, Number, Undefined several types of objects that it does not have any problems, but nothing for the Array object to use the: alert (typeof null); / / "object" alert (typeof []) ; / / "object" 2,

• JS determine full-width half-angle 2010-05-04

JS Judge the full width half-angle : function chkHalf(str){ for(var i=0;i<str.length;i++) { strCode=str.charCodeAt(i); if((strCode>65248)||(strCode==12288)){ alert(" There is a full-width characters "); break; } } } JAVA Judge the full wid

• JS determine the decimal point and so can only enter the number (rpm) 2010-06-04

JS judge only numbers and decimal points 1. Text box can only enter the numeric code (decimal point can not be input) <input onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')">

1
2
3
4
5
6
7
8
9
10