⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 p223_domains_picklists.htm

📁 javascript source code part2
💻 HTM
字号:
<HTML><BODY>
<SCRIPT LANGUAGE="JavaScript">

// an object with 12 properties
var months = { 'Jan':0,'Feb':0,'Mar':0,'Apr':0,'May':0,'Jun':0,
             'Jul':0,'Aug':0,'Sep':0,'Oct':0,'Nov':0,'Dec':0 };

//  check for times of the day
function is_time_domain(value)
{
    // the expected format is a simple Army time: 0 to 2359 
    // with no colon (:), so 23:59 is not allowed.
    // Obviously it could be more complex.

    var num = parseInt(value,10);
    if (value.length != 4 )
       return false;
    if ( num <0 || num % 100 > 59 || num / 100 > 23)
       return false;
    return true;
}

// check for months of the year
function is_month_domain(value)
{
    // Could be more tolerant of capitalisation.
    return ( months[value] != null );     // true if it's there
}

// check for anything
function check_domain(domain, value)
{
    var result = false;
    if ( domain == 'TIME' )    result = is_time_domain(value);
    if ( domain == 'MONTH' )   result = is_month_domain(value);
    if (!result)
       alert('please enter data correctly');
    return result;
}
</SCRIPT>

<FORM>
<BR> Enter an Army time:
<INPUT TYPE="text" ONCHANGE="return check_domain('TIME',this.value)">
<BR> Enter a month in short format:
<INPUT TYPE="text" ONCHANGE="return check_domain('MONTH',this.value)">
</FORM>
</BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -