javascript validation phone number
<p>alright, whats wrong with my script, JShint is throwing three lines of red code saying i have issues in my variable and my if/else statement. I am trying to validate if the phone number is a valid USA phone format</p><pre><br /><code> $( "#phone" ).focusout(function telephone() {<br /> if( this.value === "" || this.value === null ) {<br /> $( "#error_messages" ).text("");<br /> return false;<br /> } else {<br /> var re = \d{3}[\-]\d{3}[\-]\d{4};<br /> if(re.test(document.getElementById("phone").value)) {<br /> $( "#error_messages" ).text("");<br /> return true;<br /> } else {<br /> $( "#error_messages" ).text("Phone Number* not a valid format xxx-xxx-xxxx");<br /> return false;<br /> }<br /> }<br />});<br /></code><br /></pre><br /><h2>Click here view more answers <a href="%20http://stackoverflow.com/questions/34525356/javascript-validation-phone-number">http://ift.tt/22xYFRb</a></h2>
Nhận xét
Đăng nhận xét