简体   繁体   中英

bug in phone number validation

I am trying to write code for phone number validation. I need to just check whether it is a numeric value. I used the following code.

var phoneres
function checkphone(int){
    var filter=/^[0-9]{3}\-[0-9]{7}$/
    if (filter.test(int))
        phoneres=true
    else {
        phoneres=false
    }
    return (phoneres)
}

if(checkemail(document.getElementById('phone').value) == false) {
    alert("Please enter a valid Phone number!");
    return false;
}

Even i enter the valid number example 111-1234567 it displays "Please enter a valid Phone number!" .

How can i correct that?

您正在呼叫checkemail而不是checkphone功能

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM