开发者

How to test Text Field Validate a comma exists in a field

开发者 https://www.devze.com 2023-01-01 17:14 出处:网络
How开发者_如何学Python to test input FieldValidate a commaexists in a input field ?var value = document.getElementById(\'id-of-the-form-field\').value

How开发者_如何学Python to test input Field Validate a comma exists in a input field ?


var value = document.getElementById('id-of-the-form-field').value 
// or: var value = document.getElementsByName('name-of-the-form-field')[0].value

if(value.indexOf(',') > -1) {
    // value contains a comma
}

If this is not what you want, you have to give more details.

Reference: .indexOf()


str = document.getElementById(text_feild_id).value
arr = str.split(",")
if (arr.length>1){
  alert("comma exist");
}

or

   if (str.replace(/[^,]/g, "").length>=1){
      alert("comma exist");
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消