Reg exps. 내 힘이 아니야. 1-9와 많은 점을 내가 원하는대로 : 입력 지금 내가 할 수있는jQuery - Reg Exp 만 1-9 일에 한 번 포인트
var regex = new RegExp("^[(1-9)(\.)]\d*$");
: 여기에 코드를 내 라인입니다. 문제 : 사용자에게 한 점을 정확하게 쓸 수있는 기회 만 제공하고 싶습니다.
어떻게하면됩니까? 여기 내 전체 스크립트입니다 : 어떤 helpin '
Reg exps. 내 힘이 아니야. 1-9와 많은 점을 내가 원하는대로 : 입력 지금 내가 할 수있는jQuery - Reg Exp 만 1-9 일에 한 번 포인트
var regex = new RegExp("^[(1-9)(\.)]\d*$");
: 여기에 코드를 내 라인입니다. 문제 : 사용자에게 한 점을 정확하게 쓸 수있는 기회 만 제공하고 싶습니다.
어떻게하면됩니까? 여기 내 전체 스크립트입니다 : 어떤 helpin '
에 대한
jQuery(document).ready(function($) {
$('.bet-bit-input').keypress(function (e) {
var regex = new RegExp("[(1-9)(\.)]\d*$");
var str = String.fromCharCode(!e.charCode ? e.which : e.charCode);
if (regex.test(str)) {
return true;
}
e.preventDefault();
return false;
});
});
감사 ^\d+(\.\d+)?$
로 정규식을 교체하는 방법에 대해 :
^[1-9]\d*(?:\.\d+)?$
설명 :
^ the beginning of the string
----------------------------------------------------------------------
[1-9] any character of: '1' to '9'
----------------------------------------------------------------------
\d* digits (0-9) (0 or more times (matching
the most amount possible))
----------------------------------------------------------------------
(?: group, but do not capture (optional
(matching the most amount possible)):
----------------------------------------------------------------------
\. '.'
----------------------------------------------------------------------
\d+ digits (0-9) (1 or more times (matching
the most amount possible))
----------------------------------------------------------------------
)? end of grouping
----------------------------------------------------------------------
$ before an optional \n, and the end of the
string
,451,515,
정규식 ^[(1-9)(\.)]\d*$
수단 : 작동하지 않습니다
^ the beginning of the string
----------------------------------------------------------------------
[(1-9)(\.)] any character of: '(', '1' to '9', ')',
'(', '\.', ')'
----------------------------------------------------------------------
\d* digits (0-9) (0 or more times (matching
the most amount possible))
----------------------------------------------------------------------
$ before an optional \n, and the end of the
string
----------------------------------------------------------------------
) end of grouping
. ??? http://jsfiddle.net/DUQsL/ – Issis