How to check if string contains Latin characters only?

前端 未结 6 1699
旧巷少年郎
旧巷少年郎 2021-01-30 12:39

How to check if a string contains [a-zA-Z] characters only?

Example:

var str = \'123z56\';
6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-30 12:59

    Ahh, found the answer myself:

    if (/[a-zA-Z]/.test(num)) {
      alert('Letter Found')
    }
    

提交回复
热议问题