常用javascript函数(一)

作者:简简单单 2008-01-18
/*********************************************************************************
*    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); }

相关文章

精彩推荐