JS Date Email Address Verification code

Source: Internet
Author: User

Check the two-date sequence
* Return value:
* If one of the dates is null, the checksum passes and returns true
* If the start date is earlier than or equal to the expiration date, the validation passes and returns True
* If the start date is later than the end date, return false reference information: The start date cannot be later than the end date.
*/

function Checkdateearlier (strstart,strend)
{
if (checkisvaliddate (strstart) = = False | | Checkisvaliddate (strend) = = False)
return false;
If one of the inputs is empty, the check is passed
if ((Strstart = "") | | (Strend = ""))
return true;
var arr1 = Strstart.split ("-");
var arr2 = Strend.split ("-");
var date1 = new Date (Arr1[0],parseint (Arr1[1].replace (/^0/, ""),-1,arr1[2]);
var date2 = new Date (Arr2[0],parseint (Arr2[1].replace (/^0/, ""),-1,arr2[2]);
if (arr1[1].length = 1)
ARR1[1] = "0" + arr1[1];
if (arr1[2].length = 1)
ARR1[2] = "0" + arr1[2];
if (arr2[1].length = 1)
ARR2[1] = "0" + arr2[1];
if (arr2[2].length = 1)
arr2[2]= "0" + arr2[2];
var D1 = arr1[0] + arr1[1] + arr1[2];
var D2 = arr2[0] + arr2[1] + arr2[2];
if (parseint (d1,10) > parseint (d2,10))
return false;
Else
return true;
}//


JS Email Address Verification

* Check whether the string is email type
* Return value:
* If NULL, define checksum pass, return True
* If the string is email type, check pass, return True
* If the email is not valid, return FALSE reference message: Email format is not right!
*/

function   checkemail (str)   
{  
//If NULL, pass checksum   
if (str   ==   "")   
return   true;  
if   (str. Charat (0)    ==   "."    | |    Str.charat (0)    ==   "@"    | |    str.indexof (' @ ',   0)    ==   -1  
| |    str.indexof ('. ',   0)    ==   -1   | |    str.lastindexof ("@")    ==   str.length-1   | |    str.lastindexof (".")    ==   str.length-1)   
return   false;  
else   ;
return   true;  
}//

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.