一聚教程网:一个值得你收藏的教程网站

热门教程

常用javascript函数(一)

时间:2022-06-30 09:43:39 编辑:袖梨 来源:一聚教程网

/*********************************************************************************
*    FUNCTION:        isBetween
*    PARAMETERS:        val        AS any value
*          lo        AS Lower limit to check
*          hi        AS Higher limit to check
*    CALLS:       NOTHING
*    RETURNS:        TRUE if val is between lo and hi both inclusive, otherwise false.
**********************************************************************************/
function isBetween (val, lo, hi) {
    if ((val < lo) || (val > hi)) { return(false); }
    else { return(true); }
}
/*********************************************************************************
*    FUNCTION:        isDate checks a valid date
*    PARAMETERS:        theStr        AS String
*    CALLS:       isBetween, isInt
*    RETURNS:        TRUE if theStr is a valid date otherwise false.
**********************************************************************************/
function isDate (theStr) {
    var the1st = theStr.indexOf('-');
    var the2nd = theStr.lastIndexOf('-');
    
    if (the1st == the2nd) { return(false); }

热门栏目