gpt4 book ai didi

javascript - jQuery/JavaScript 验证城市、州 ZIP 单个字段

转载 作者:行者123 更新时间:2023-11-30 10:48:16 25 4
gpt4 key购买 nike

我有一个用于城市、州(两个字母)和邮政编码(5 位数字)的输入字段。格式为“城市、州 ZIP”。

谁能提供我如何验证此格式和字符?

谢谢!

最佳答案

您可以使用正则表达式:http://jsfiddle.net/pimvdb/AeKdj/ .

/[\w ]+, \w{2} \d{5}/

地点:

[\w ]+   means more than one of letter or space
\w{2} means exactly two letters
\d{5} means five digits

例如

/[\w ]+, \w{2} \d{5}/.test(textbox.value);

关于javascript - jQuery/JavaScript 验证城市、州 ZIP 单个字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7058641/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com