Dedecms custom form Submission Verification mobile phone number of mailboxes and other methods

Source: Internet
Author: User

First paste out the JS code

The code is as follows Copy Code
<script>
function Check ()
{
Name=document.getelementbyidx_x_x ("Fzrxm"). Value;
if (name== "")
{
Alert ("Enter your name!") ")
return false;
}

Re =/^1\d{10}$/
Tel=document.getelementbyidx_x_x ("Lxdh"). Value;
if (Re.test (tel)) {

} else {
Alert ("Please enter the correct cell phone number!") ");
return false;
}

EM =/^ ([a-za-z0-9_\.\-]) +\@ (([a-za-z0-9\-]) +\.) + ([a-za-z0-9]{2,4}) +$/;
Eml=document.getelementbyidx_x_x ("Lxqq"). Value;
if (Em.test (EML)) {

}else{
Alert ("Please enter the correct mailbox!") ");
return false;
}


}
</script>

PHP validation

The code is as follows Copy Code

$email = "tanklo_--vehy@yahoo.com.cn";
function Check_email ($email) {
$pattern _test = "/([A-z0-9]*[-_.]? [a-z0-9]+) *@ ([a-z0-9]*[-_]?[ a-z0-9]+) +[.] [A-z] {2,3} ([.] [A-z] {2})? /I ";
Return Preg_match ($pattern _test, $email);
}
echo Check_email ($email);


function Is_mobile ($STR) {
Return Preg_match (/^ (d{3}) | ( d{3}-))? 13d{9}$/", $STR);
}

Next, when the form form is submitted, add

  code is as follows copy code
<form action= "/plus/diy.php" enctype= "Multipart/form-data" method= "POST"   onsubmit= "return check ()"

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.