esffor 发表于 2013-2-6 10:12:23

简单的可重用的输入验证

很简单,如果该输入的没有输入,则弹出提示
common.js:
 
<div style="padding-right: 5.4pt; padding-left: 5.4pt; background: #e6e6e6; padding-bottom: 4px; width: 95%; padding-top: 4px;">http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.giffunction isRequired( checked )
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif    for( var i=0; i<checked.length; i++ )
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif    ...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif        var input = checked[0];
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif        if( input.value==null || input.value.length==0 )
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif        ...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif            alert( checked[1] );
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif            input.focus();
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif            return false;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif        }
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif    }
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif    return true;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif}
页: [1]
查看完整版本: 简单的可重用的输入验证