This article describes the detailed instance code of common JavaScript advanced (3) Tools (verification and general). For more information, see common JS tools (verification and General) // name verification.
Var checkName = function (name) {// consignee name verification (criterion: name is 2-4 characters) var regu =/^ [\ u4E00-\ u9FA5] {2, 4} $ /; var re = new RegExp (regu); if (! Re. test (name) {return false;} return true ;};
// Mobile phone number verification
var checkCellphone = function(cellPhone){var regu = /^[S|U]((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0,2,3,5-9]))\d{8}$/;var re = new RegExp(regu);if (!re.test(cellPhone)) {return false;}return true;};
// Convert the Date Format
var formatDateTime = function (date){ if(date == null){return null;}else{var y = date.getFullYear(); var m = date.getMonth() + 1; m = m < 10 ? ('0' + m) : m; var d = date.getDate(); d = d < 10 ? ('0' + d) : d; var h = date.getHours(); var minute = date.getMinutes(); minute = minute < 10 ? ('0' + minute) : minute; var second = date.getSeconds();return y + '-' + m + '-' + d +' ' + h + ':'+minute+':'+second; }};
// Get the current time in the format of YYYY-MM-DD
Var CurentTime = function () {var now = new Date (); var year = now. getFullYear (); // year var month = now. getMonth () + 1; // month var day = now. getDate (); // var clock = year + ""; if (month <10) clock + = "0"; clock + = month + ""; if (day <10) clock + = "0"; clock + = day + ""; return (clock );};
// Verify the password format
var checkPasswd = function(passwd){var myreg = /^(\w|[a-z]){6,9}$/;var re = new RegExp(myreg);if(!re.test(passwd)){ return false;}return true;};
The above is the content of common JavaScript advanced (3) Tools (verification and general). For more information, see PHP Chinese website (www.php1.cn )!