我已经创建了一个表单,需要通过它的内容(空,!空)和电话号码字段验证字段,以便电话号码匹配regex (乌克兰电话号码)。此选项不起作用(
const regex = /^\+[0-9]{3}\s\((\d+)\)-\d{3}-\d{2}-\d{2}/g
const validate = (username, phone, comment) => {
if ((username.length === 0 || phone.length === 0, comment.length === 0)) {
setErrorEmpty('the field is empty !')
} else if (!phone.match.regex) {
setPhoneErr('the format is wrong !')
} else {
setValidated(true)
}
}乌克兰号码由10位数字组成:例如:0954343333或(38)0954343333
发布于 2021-04-28 17:30:36
https://stackoverflow.com/questions/67297303
复制相似问题