The phone number and the email must be valid.
This is a basic popup contact form without the phone number validation. I would like to validate the phone number. I heard about regex but i´m not sure how to implement in the code.
Since i don´t understand javascrip yet i hope you can help me.
<form action="#" method="post" id="form">
    <h2>Contact Us</h2><hr/>
    <input type="text" name="company" id="company" placeholder="Company"/>
    <input type="text" name="name" id="name" placeholder="Name"/>
    <input type="text" name="email" id="email" placeholder="Email"/>
    <input type="text" name="phone" id="email" placeholder="Phone"/>
    <a id="submit" href="javascript: check_empty()">Send</a>
</form>
function check_empty(){
    if(document.getElementById('company').value == "" 
    || document.getElementById('name').value == ""
    ||document.getElementById('email').value == ""
    ||document.getElementById('phone').value == "" ){
    alert ("Please, fill the fields!");
    }
    else {  
        document.getElementById('form').submit();
    }
}
//function to display Popup
function div_show(){ 
    document.getElementById('abc').style.display = "block";
}
//function to check target element
function check(e){ 
    var target = (e && e.target) || (event && event.srcElement); 
    var obj = document.getElementById('abc'); 
    var obj2 = document.getElementById('popup'); 
    checkParent(target)?obj.style.display='none':null; 
    target==obj2?obj.style.display='block':null; 
} 
//function to check parent node and return result accordingly
function checkParent(t){ 
    while(t.parentNode){ 
        if(t==document.getElementById('abc'))
            { 
                return false 
            }
        else if(t==document.getElementById('close'))
            {
                return true
            } 
        t=t.parentNode 
    } 
    return true 
} 
 
    