javascript×÷±íμ¥ê?è?ààDíμ??é?¤

var today = new Date();
var sError="";
String.prototype.trim = function(){
return this.replace(/(^\s*)|(\s*$)/g, "");
}
String.prototype.ltrim = function(){
return this.replace(/^\s*/g,"");
}
String.prototype.rtrim = function(){
return this.replace(/\s*$/g,"");
}
function trim(){
if(arguments.length<1)
?? return null;
if(typeof(arguments[0])=="string")
?? return arguments[0].replace(/(^\s*)|(\s*$)/g, "");
else
?? return "";
}
function ltrim(){
if(arguments.length<1)
?? return null;
if(typeof(arguments[0])=="string")
?? return arguments[0].replace(/(^\s*)/g, "");
else
?? return "";
}
//×?·?è¥3y×óóò????oˉêy
function rtrim(){
if(arguments.length<1)
?? return null;
if(typeof(arguments[0])=="string")
?? return arguments[0].replace(/(\s*$)/g, "");
else
?? return "";
}
//êy×?D£?éoˉêy ê?·?ê?êy×?
function __isNum(s)
{
var re = /^[0-9]+$/;
return re.test(s);
}
//ê?·?ê?Float
function __isFloat(s)
{
if (__isNum(s)) return true;
var re = /^[+|-]{0,1}\d*\.?\d+$/;
return re.test(s);
}
//ê?·?ê????§??êy·¨Float
function __isEFloat(s)
{
??? var re = /^[+|-]{0,1}\d*\.[\.\d+]{0,1}\e[-|+]{0,1}\d+$/;
??? return re.test(s);
}
//ê?·?óDì?êa·?o?
function __isQuoteIn(s)
{
var re = /\"|\'|\?°|\?±|\??|\?ˉ|\%|\$|\£¤|\?-?-|\?¤|\?a|\-|\?a?a|\!|\£?|\#|\@|\~|\^|\*|\,|\.|\£?|\?£|\?|\£?|\; |\£?|\:|\£o|\{|\}|\\|\/|\[|\]|\(|\)|\+|\-|\?¢|\||\<|\>/;
return re.test(s);
}
//??êy 2¢?òD?óúmax£?′óóúmin 2?êy ???óobject £?max£?min
function isIntegerMaxMin(ob,max,min){
var value=https://www.it610.com/article/parseInt(ob.value);
return ((value=https://www.it610.com/article/=ob.value)&&(valuemin));
}
//ê?·?ê???êy 2?êy ???ó
function isInteger(ob,type){
//var value=https://www.it610.com/article/parseInt(ob.value);
//return (value=https://www.it610.com/article/=ob.value);
if(type=="positive")
return /^\+?\d+$/g.test(ob.value);
else if (type=="negative")
return /^-\d+$/g.test(ob.value);
else
return /^(?:-?|\+?)\d+$/g.test(ob.value);
}
//?D?????óμ??μê?·?ê?êy×? 2?êy ???ó
function checkNum(eSrc)
{
var value = https://www.it610.com/article/eSrc.value;
return __isNum(value);
}
//?D?????óμ??μê?·?ê?D?êyêy×? 2?êy ???ó
function checkFloat(eSrc)
{
var value = https://www.it610.com/article/eSrc.value;
return __isFloat(value);
}
//?D?????óμ??μê?·?ê????§??êyêy×? 2?êy ???ó
function checkEFloat(eSrc)
{
var value = https://www.it610.com/article/eSrc.value;
return __isEFloat(value);
}
//×?·?ê?·?£?
function __isNumChar(ch)
{
return (ch >= '0' && ch <= '9');
}
//ê?·?ê?????£?×aDDμè
function __isBlankChar(ch)
{
//è¥μ?á?'\v'; 20020522??
return (ch == ' ' || ch == '\f' || ch == '\n' || ch == '\r' || ch=='\t');
}
//??μ?×?·?′?μ?3¤?è?? ò???oo×???2??×??ú
function byteLength(str)
{
var re=/[\u4E00-\u9FA5]/g;
if(re.test(str))
??? return str.length+str.match(re).length;
else return str.length;
}
//D£?é×?·?3¤?è1?12oˉêy ???óob,×?′ó3¤?èmaxLen£????¢message
function stringLengthCheck(ob,maxLen,message){
if(byteLength(trim(ob.value))>maxLen){
?? alert(message);
?? return false;
}
return true;
}
//??μ?μ±?°è??ú
function __getCurrentDate()
{
var date = new Date();
var year = ""+date.getFullYear();
var month = date.getMonth()+1;
if(month<10){ month="0"+month; }
var day = date.getDate();
if(day<10){ day = "0"+day; }
return year+month+day;
}
//êy?§oˉêy ??ê??ˉêy?Y(??è?D?êy??éá??è?)?? 2?êy ???ó?μvalue£?D?êy??
function __formatNum(value,scale){
var f = parseFloat(value);
if(scale<0)scale=0;
return f.toFixed(scale);
}
//êy?§oˉêy ??ê??ˉêy?Y?? 2?êy ???ó?μvalue£?D?êy??
function __setScale( value , scale )
{
if( isNaN( value ) || isNaN( scale ) || parseInt( scale ) < 0 )
?? return new String( value ) ;
var strValue = https://www.it610.com/article/new String( value ) ;
var fValue = https://www.it610.com/article/parseFloat( value ) ;
var iScale = parseInt( scale ) ;

if( iScale == 0 )
?? return new String( ( fValue < 0.0 ? "-" : "" ) + Math.round( Math.abs( fValue ) ) ) ;
??
if( fValue =https://www.it610.com/article/= parseInt( strValue ) ) //′?è?μ?2?êy??óDD?êy2?·?
{
?? strValue = https://www.it610.com/article/new String( parseInt( strValue ) ) +"." ;
?? for( var i = 0 ; i < iScale ; i ++ )
??? strValue += "0" ;
}
else
{
?? var fDecimal = Math.abs( fValue - parseInt( strValue ) ) ;
?? fDecimal = Math.round( fDecimal * Math.pow( 10 , iScale ) ) ;
?? var strDecimal = new String( fDecimal ) ;
?? //??óú?? new String( Math.round( 0.07 * Math.pow( 10 , 2 ) ) ) == "7" but not "07" ?a?ùμ??é??Dèòa×÷ò???21á?′|àí
?? if( strDecimal.length < iScale )
?? {
??? var iDecimalLength = strDecimal.length ;
???
??? for( var i = 0 ; i < iScale - iDecimalLength ; i ++ )
???? strDecimal = "0" + strDecimal ;

??? strValue = https://www.it610.com/article/new String( parseInt( strValue ) ) +"." + strDecimal ;
?? }
?? //??óú?? new String( Math.round( 0.995 * Math.pow( 10 , 2 ) ) ) == "100" ?a?ùμ??é??Dèòa×÷ò???21á?′|àí
?? else if( strDecimal.length > iScale )
?? {
??? strValue = https://www.it610.com/article/new String( parseInt( strValue ) + 1 ) ; ???
???
??? strValue += "." ;
??? for( var i = 0 ; i < iScale ; i ++ )
???? strValue += "0" ;
?? }
?? else
??? strValue = https://www.it610.com/article/new String( parseInt( strValue ) ) +"." + strDecimal ;
}

return strValue ;
}

//éí·Y?¤μ??é?¤ 2?êy ?μ
function __isIdCardNo(num)
{
var a=null;
var len = num.length, re;
if (isNaN(num)) {
?? //x?á?2
?? re = new RegExp(/^(\d{6})()?(\d{4})(\d{2})(\d{2})(\d{3})([xX])$/);
?? a=num.match(re);
?? if(a!=null){???
?? }else{
??? alert(sotowerfunction_msg_1);
??? return false;
?? }
}else{
if (len == 15)
?? re = new RegExp(/^(\d{6})()?(\d{2})(\d{2})(\d{2})(\d{3})$/);
else if (len == 18)
re = new RegExp(/^(\d{6})()?(\d{4})(\d{2})(\d{2})(\d{3})(\d)$/);
else {alert(sotowerfunction_msg_2); return false; }
var a = num.match(re);
}
if (a != null)
{
if (len==15)
{
?? var D = new Date("19"+a[3]+"/"+a[4]+"/"+a[5]);
?? var B = D.getYear()==a[3]&&(D.getMonth()+1)==a[4]&&D.getDate()==a[5];
}
else
{
?? var D = new Date(a[3]+"/"+a[4]+"/"+a[5]);
?? var B = D.getFullYear()==a[3]&&(D.getMonth()+1)==a[4]&&D.getDate()==a[5];
}
if (!B) {alert(sotowerfunction_msg_3+ a[0] +sotowerfunction_msg_4); return false; }
}
return true;
}
//D£?é?e??ê?·?o??? like 9.9999
function __checkMoney(str){
if (trim(str)==""){
?? sError=sotowerfunction_error_8; ??
?? return false;
}
if(isNaN(trim(str))){
?? sError=sotowerfunction_error_9; ??
?? return false;
}
var nreg = /(^[0-9]+$)|(^[0-9]+)(.[0-9]+$)/;
var nr = str.match(nreg);
if(nr==null){
?? sError=sotowerfunction_error_10; ??
?? return false;
}else{
?? return true;
}
}
//í¨3£?e??ê?á??? like 9.99
function __checkMoneyFix(str,n){
if (trim(str)==""){
?? sError=sotowerfunction_error_8; ??
?? return false;
}
if(isNaN(trim(str))){
?? sError=sotowerfunction_error_9; ??
?? return false;
}
var nreg = /(^[0-9]+$)|(^[0-9]+)(.[0-9]+$)/;
var nr = str.match(nreg);
if(nr==null){
?? sError=sotowerfunction_error_10; ??
?? return false;
}else{
?? var index=str.indexOf(".")+1;
?? var ss=str.substring(index);
?? if(ss.length==n){
?? return true;
?? }else{
??? return false;
?? }
}
}
//D£?éóê?? 2?êy ???ó.value
function __checkEmail(email)
{
// a very simple email validation checking.
// you can add more complex email checking if it helps
??? var splitted = email.match("^(.+)@(.+)$");
??? if(splitted == null) return false;
??? if(splitted[1] != null )
??? {
????? var regexp_user=/^\"?[\w-_\.]*\"?$/;
????? if(splitted[1].match(regexp_user) == null) return false;
??? }
??? if(splitted[2] != null)
??? {
????? var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
????? if(splitted[2].match(regexp_domain) == null)
????? {
???? var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
???? if(splitted[2].match(regexp_ip) == null) return false;
????? }// if
????? return true;
??? }
return false;
}
//checkbox è????D 2?êy checkboxμ?name, ê?·?ture,false
function __checkAll(name,tf)
{
var a = document.getElementsByName(name);
var n = a.length;
for (var i=0; ia[i].checked = tf;
}
//checkbox ê?·?óD???D 2?êy checkboxμ?name ·μ???μ?a???Dμ???êy£???óD???Dê±·μ?? 0
function __checkSelectCheckbox(name)
{
var a = document.getElementsByName(name);
var n = a.length;
var isCheck=0;
for (var i=0; i?? if(a[i].checked){
??? isCheck++;
?? }
}
return isCheck;
}
//è??úD£?éoˉêy 20040501
function __checkStdDate(eSrc)
{
var value = https://www.it610.com/article/eSrc.value;
if (!__isNum(value)) {
?? sError = sotowerfunction_error_11;
?? return false;
}
if (value.length != 8) {
?? sError = sotowerfunction_error_12;
?? return false;
}
var year = value.substring(0,4);
var month = value.substring(4,6);
var day = value.substring(6,8);
var y = year * 1;
var m = month * 1;
var d = day * 1;
var bReturn = __isLegalDate(y,m,d);
return bReturn;
}
//è??úD£?éoˉêy 200405
function __checkStdMonth(eSrc)
{
var value = https://www.it610.com/article/eSrc.value;
if (!__isNum(value)) {
?? sError = sotowerfunction_error_11;
?? return false;
}
if (value.length != 6) {
?? sError = sotowerfunction_error_12;
?? return false;
}
??? var year = value.substring(0,4);
var month = value.substring(4,6);
var bReturn = __isLegalMonth(year,month);
return bReturn;
}
//??·YD£?é 1--12
function __checkMonth(eSrc)
{
??? var value = https://www.it610.com/article/eSrc.value;
??? if (!__isNum(value)) {
?? sError = sotowerfunction_error_13;
?? return false;
}
??? if(value < 1 || value > 12)
???? {
???? sError = sotowerfunction_error_14;
???? return false;
???? }
?? return true;
}
//?ê·YD£?é
function __checkStdYear(eSrc)
{
var value = https://www.it610.com/article/eSrc.value;
if (value.length != 4) {
?? sError = sotowerfunction_error_12;
?? return false;
}
if (!__isNum(value)) {
?? sError = sotowerfunction_error_11;
?? return false;
}
var year = value;
var bReturn = __isLegalYear(year);
return bReturn;
}
//121212?? 12μ?12·?12??
function __checkStdTime(eSrc)
{
?? var value = https://www.it610.com/article/eSrc.value;
if (value.length != 6) {
?? sError = sotowerfunction_error_12;
?? return false;
}
if (!__isNum(value)) {
?? sError = sotowerfunction_error_16;
?? return false;
}
var hour = value.substring(0,2);
var minute = value.substring(2,4);
var second = value.substring(4,6);
var bReturn = __isLegalTime(hour, minute, second);
return bReturn;
}
//?ê??è?D£?é2004/05/01
function __checkSlashStdDate(eSrc)
{
var value = https://www.it610.com/article/eSrc.value;
if (value.length != 10) {
?? sError = sotowerfunction_error_12;
?? return false;
}
var re = /\d{4}\/\d{2}\/\d{2}/;
if (!re.test(value)) {
?? sError = sotowerfunction_error_17;
?? return false;
}
var year = value.substring(0,4);
var month = value.substring(5,7);
var day = value.substring(8,10);
var bReturn = __isLegalDate(year,month,day);
if (false == bReturn)
?? return false;
return true;
}
//ê?·?o?·¨μ?è??ú£?month ?ùóú0
function __isLegalDate(year,month,day)
{
???? if(year < 0 || year > 9999)
???? {
???? sError = sotowerfunction_error_18;
???? return false;
???? }
???? if(month < 1 || month > 12)
???? {
???? sError = sotowerfunction_error_14;
???? return false;
???? }
???? if(day < 1)
???? {
???? sError = sotowerfunction_error_19;
???? return false;
???? }
???? if (day > 31)
???? {
???? sError = sotowerfunction_error_20;
???? return false;
???? }
???? if(month == 2)
???? {
???? if( __isLeapYear(year) )
???? {
??????? if(day > 29)
??????? {
???????? ?? sError = sotowerfunction_error_21;
???????? ?? return false;
???????? }
?? }
?? else
?? {
??? if(day > 28)
??? {
???? sError = sotowerfunction_error_22;
???? return false;
??? }
?? }
} else
{
?? var d1, m1=month;
?? if(m1 > 7)
??? m1 = m1 + 1;
?? d1 = 30 + m1 % 2;
?? if(day > d1)
?? {
??? sError = sotowerfunction_error_23 + d1 +sotowerfunction_error_24;
??? return false;
?? }
}
return true;
}
//ê?·?ê?èó?ê
function __isLeapYear(year)
{
if( ( year % 400 == 0) || (( year % 4 == 0) && (year % 100 != 0)) )
?? return true;
else
?? return false;
}
//ê?·?o?·¨μ???£?
function __isLegalMonth(year,month)
{
???? if(year < 0 || year > 9999)
???? {
???? sError = sotowerfunction_error_18;
???? return false;
???? }
???? if(month < 1 || month > 12)
???? {
???? sError = sotowerfunction_error_14;
???? return false;
???? }
return true;
}
//ê?·?o?·¨μ??ê£?
function __isLegalYear(year)
{
???? if(year < 0 || year > 9999)
???? {
???? sError = sotowerfunction_error_18;
???? return false;
???? }
return true;
}
//ê?·?ê?o?·¨μ?ê±·???
function __isLegalTime(hour, minute, second)
{
???? if(hour < 0 || hour > 23)
???? {
???? sError = sotowerfunction_error_25;
???? return false;
???? }
???? if(minute < 0 || minute > 59)
???? {
???? sError = sotowerfunction_error_26;
???? return false;
???? }
???? if (second < 0 || second > 59)
???? {
???? sError = sotowerfunction_error_27;
???? return false;
???? }
return true;
}
/*********************************
*?D??ê?·?ê?μ¥×??úa-zA-Z0-9_-???D
**********************************/
function isSingleFormat(str)
{
var singleFormat = /^[.a-zA-Z0-9_-]+$/;
if(!singleFormat.test(str))
{
?? return false;
}
return true;
}
/**************************************
*?D??ê?·?ê??oêy
***************************************/
function checkNegative(arg){??
if(isNaN(arg)){
?? if(arg.value<0){
??? return true;
?? }
?? return false;
}
if(arg*1<0){
?? return true;
}
return false;
}
//ê±????ê?μ??ì?é êêo?óú20:30:59??ê?
function __checkTime(s){
?? var rs= /^\d{2}\:\d{2}\:\d{2}$/;
?? if(!rs.test(s)){
???? return false;
?? }
?? var arr = s.split(":");
?? if(parseInt(arr[0])>24||parseInt(arr[1])>59||parseInt(arr[2])>59){
?? return false;
?? }
?? return true;
}
//±è???aê?è??úoí?áê?è??ú baixchìí?ó20050416
function __compareDate(startDate,endDate){
var startD = startDate.value;
var endD = endDate.value;
if(startD==endD){
?? return 0;
?? }
else if(startD>endD){
?? return -1
}
else if(startD?? return 1;
}??
}
//?ì?é′ú????ê? ò?°??é????′ú?????üóéó¢??×?·??òêy×?×é3é,2??üo?óD?D??
function __checkCode(s){
?? var rs = /^([0-9]|[a-z]|[A-Z])+$/;
?? if(!rs.test(s)){
??? return false;
?? }
?? return true;
}
//?ì?éIPμ??·μ?o?·¨D? àyè?:10.162.11.104ê??yè·μ?IPμ??·
function __checkIp(s){
var re = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
if(!re.test(s)){
???? return false;
}
var ips=s.split(".");
if((ips[0].indexOf("0")==0)||(ips[1].indexOf("0")==0)||(ips[2].indexOf("0")==0)||(ips[3].indexOf("0")==0)){
???? return false;
}
if(ips[0]>255 || ips[1]>255|| ips[2]>255 || ips[3]>255 ){
???? return false;
}
return true;
}
//?ì?é?D1úóê±à ???üê?6??êy×?
function __checkChinaPostCode(s){
var rs=/\d{6}/;
if(!rs.test(s)){
?? return false;
}
??????? return true;
}
//?D??×?·?′?ê?·?ê?1ì?¨μ??°o???×?·?′?£?è?ê??ò·μ??true£?·??ò·μ??false
function __isFixedTelephone(s){
return /^(\d{2,4}-)?((\(\d{3,5}\))|(\d{3,5}-))?\d{3,8}(-\d+)?$/g.test(s);
}
//?D??×?·?′?ê?·?ê?ê??úμ??°o???×?·?′?£?è?ê??ò·μ??true£?·??ò·μ??false
function __isMobileTelephone(s) {
return /^1(3\d|(58|59|56|52|53|50))\d{8}$/g.test(s);
}
//?D??×?·?′?ê?·?ê?μ??°o???×?·?′?£?è?ê??ò·μ??true£?·??ò·μ??false
function __isTelephone(s) {
return __isMobileTelephone(s) || __isFixedTelephone(s);
}
//?D??×?·?′?ê?·?ò?×????aí·£??????a×???oíêy×?×éo?
function __checkCodeFormat(s) {
return /^[A-Za-z][A-Za-z0-9_]{0,}$/g.test(s);
}
/**
* XMLHTTP ìá??
**/
//í¨1yxmlhttpè??μ£?·μ??×?·?′?
function getHtmlStringByXmlhttp(url)
{
if(url==null)
{
alert(sotowerfunction_msg_5);
return;
}
try
?? {
?? var xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
?? if(xmlhttp==null)
?? {
?? alert(sotowerfunction_msg_6+ex.description);
?? return ;
?? }
?? xmlhttp.open("POST",url,false);
?? xmlhttp.send();
?? return xmlhttp.responseText;
?? }catch(ex)
?? {
?? alert(sotowerfunction_msg_7+ex.description);
?? return "";
?? }
}

function getArrayByXmlHttp(urll){
var values=getHtmlStringByXmlhttp(urll);
???? if(values.indexOf("??óD????")>-1){
?????? return -1;
???? }
var arr=new Array();
var obs=values.split("@|@");
for(var i=0; iobsv=obs[i].split("@,@");
arr[i]=obsv; ??
}
return arr;
}
【javascript×÷±íμ¥ê?è?ààDíμ??é?¤】function setButtonDisabled(condition) {
?? var canDisable = (window.event != null && window.event.srcElement != null && window.event.srcElement.tagName.toLowerCase() == "button");
?? if (canDisable&&condition) {
??? window.event.srcElement.disabled = true;
?? }
?? }

    推荐阅读