2
だから私はこれを持っている:jqueryバリデーションプラグインで少なくとも2つの単語をチェックする方法は?
jQuery.validator.addMethod("tagcheck", function(value, element) {
var space = value.split(' ');
return value.indexOf(" ") > 0 && space[1] != '';
}, "At least two words.");
は完璧に動作しますが、私は、単語間の最初の文字または2つのスペースの前にスペースがある場合、その作業はありません。
これは、最初の文字の前にスペースがあり
var string = "one two";
var space = string.split(" "); // ["one", "", "two"] There is a space between the first
// space and second space and thats null.
: おかげ
ありがとう:jQuery.validator.addMethod( "tagcheck"、機能(値、要素){ 戻りvalue.match( "(\\ W + )(\\ s +)(\\ w +) "); }、"少なくとも2単語。 – passatgt