At least one number in input field (jQuery)

无人久伴 提交于 2019-12-13 10:18:24

问题


I have an input field, where user has to add his address, but I need to get at least one number (house number). How should I validate that field ? Thanks in advance for any help.


回答1:


Answering the question, to see if a string contains at least one number :

if ( string.match(/\d/) ) {
    // do something
}

FIDDLE



来源:https://stackoverflow.com/questions/17364013/at-least-one-number-in-input-field-jquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!