How to check if string contains Latin characters only?

前端 未结 6 1704
旧巷少年郎
旧巷少年郎 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 13:07

    There is no jquery needed:

    var matchedPosition = str.search(/[a-z]/i);
    if(matchedPosition != -1) {
        alert('found');
    }
    

提交回复
热议问题