2
我能夠檢查輸入是否包含特定字符。但我想知道該輸入文本是否包含該字符的多個。如何檢查標籤是否僅包含jQuery中的特定字符
例如,
當我有隻「」在一個文本框,我能夠在它之前處理的話,但我要檢查,如果整個文本中包含多個逗號。例如,當我按「,,,」時。
任何幫助檢查它會做。
感謝
這裏是我的代碼:
function changeSubject(current_value) {
if (current_value != "," && current_value != "") {
var new_value = current_value.slice(0, -1);
$(".main-tag-elements").append("<span>" + new_value + "<a class='delete-tag'></a></span>");
$(".tag-input").val("");
if ($("#ClassroomSubject").val() == "") {
$("#ClassroomSubject").val(new_value);
} else {
$("#ClassroomSubject").val($("#ClassroomSubject").val() + "," + new_value);
}
}
}
請張貼一些代碼。 – j08691 2013-02-28 03:33:05
'/ ,, + /。test(text)' – 2013-02-28 03:34:06