A way to determine if a certain character contains a phone number

Source: Internet
Author: User
Tags contains

<script language= "javascript"
<!--
function Checknum (str) {return!/\d{6}/.test (str)}
function Check ()
{
if (document.form.tell.value== "") {
  alert ("Please enter the phone number!") ");
  Document.form.tell.focus ();
  return false;
}
else{
  var letters = "0123456789 () +-";
  for (i=0; i< document.form.tell.value.length; i++) {
     var Checkchar = Document.form.tell.value.charAt (i);
     if (letters.indexof (checkchar) = = 1) {
       alert (" The phone number is not in the correct format! ");
       Document.form.tell.focus ();
       return false;
     }
   }
 }
}
//-->
</script>

<form method= "POST" Name=form action= "" >
<p align= "center" >
Please enter the phone number: <input type= "text" name= "Tell" size= ">"
<input type= "Submit" value= "submitted" name= "B1" ></p>
</form>



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.