`

confirm用法和例子

阅读更多
一般用于弹出对话框(确定/否)
确定:就执行其嵌套的内容;否:则反之

<script language="javascript">   
//验证时间格式  YYYY-MM-DD/YYYY,MM,DD   
function isDate(date){   
    var regu = "^[0-9]{4}-([0-1]?)[0-9]{1}-([0-3]?)[0-9]{1}$";   
    var re   = new RegExp(regu);   
    if (date.search(re) != -1)   
        return true;   
    else  
        return false;   
}    
function sureButton(){   
   if(!confirm('真的要删除吗?删除后将无法恢复!')){   
       return;   
   }   
   //验证时间格式  YYYY-MM-DD   
  
       var startDate=document.getElementById("startDate").value;   
       var endDate=document.getElementById("endDate").value;    
       if(!isDate(startDate)){   
                   
             alert(startDate+"请输入正确的开始日期格式!如:(YYYY-MM-DD)2008-01-01");   
             return document.getElementById("startDate").focus();   
       }   
       if(!isDate(endDate)){   
             alert("请输入正确的结束日期格式!如:(YYYY-MM-DD)2008-01-01");   
             return document.getElementById("endDate").focus();   
       }   
         if(startDate==""){   
    alert("请输入开始日期");   
    return document.getElementById("startDate").focus();   
   }   
   if(endDate==""){   
    alert("请输入结束日期");   
    return document.getElementById("endDate").focus();   
   }    
   startDate=startDate.replace(new RegExp('-', 'g'),'/');   
   alert(startDate);   
   endDate=endDate.replace(new RegExp('-', 'g'),'/');   
   var startTime=new Date(startDate).getTime();   
   alert(new Date(startDate).getTime());   
   var endTime=new Date(endDate).getTime();   
   if((endTime-startTime)<0){   
    alert("结束日期必须大于开始日期");   
        return document.getElementById("endDate").focus();   
   }      
      
      
}   
</script>  


<html>    
<head>   
<meta http-equiv="Content-Language" content="zh-cn">   
<meta name="generator" content="Bluefish 1.0.7">   
<meta name="ProgId" content="FrontPage.Editor.Document">   
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">   
<title></title>   
<style type="text/css">   
  table{color: #000000; font-family: 宋体; font-size: 12px; height:12 }   
  t1{color:#008000;align:center}   
</style>   
</head>   
  
<body topmargin="0" leftmargin="0">   
  
<div align="left">   
  <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="461" height="8" id="AutoNumber1" background="images/kabg.gif">   
    
    <tr>   
      <td  colspan="3">   
      <table cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" height="17">   
          <tr>   
       <td width="19%" height="25" align="center" style="border:1px solid #000080;"><font color="#008000">开始日期</font></td>   
       <td width="31%" style="border:1px solid #000080;">    
              <input name="startDate" type="text" id="startDate" size="15"></td>   
       <td width="22%" align="center" style="border:1px solid #000080;"><font color="#008000">结束日期</font></td>   
       <td width="28%" style="border:1px solid #000080;">    
              <input name="endDate" type="text" id="endDate" size="15"></td>   
       </tr>   
       </table>   
       </td>   
    </tr>   
  
    <tr>   
      <td height="28" align="center" style="border:1px solid #000080; " colspan="3">   
      <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber3" height="17">   
        <tr>   
          <td width="14%" align="center" height="25">   
      <font color="#008000">当前状态</font></td>   
          <td width="18%" align="center" height="25">   
      <select size="1" name="display">   
      <option value="0">无效</option>   
      <option value="1">等待</option>   
      <option value="2" selected>显示中</option>   
      </select></td>   
          <td width="15%" align="center" height="25" style="border-left: 1px solid #000080; border-right-width: 1; border-top-width: 1; border-bottom-width: 1">   
          <font color="#008000">Logo行宽</font></td>   
          <td width="10%" align="center" height="25">   
      <select size="1" name="colValue">   
      <option>1</option>   
      <option>2</option>   
      <option>3</option>   
      <option>4</option>   
      <option>5</option>   
      <option>6</option>   
      </select></td>   
       <td width="12%" align="center" style="border-left: 1px solid #000080; border-right-width: 1; border-top-width: 1; border-bottom-width: 1"><font color="#008000">显示顺序</font></td>   
       <td width="5%" >    
              <input name="displayOrder" type="text" id="displayOrder" size="3" value="1">   
     </td>   
          <td width="43%" align="center" height="25" style="border-left-style: solid; border-left-width: 1; border-right-width: 1; border-top-width: 1; border-bottom-width: 1">   
      <input onclick="cancelButton()" type="reset" value="关闭" name="B2" style="border-style: outset; border-width: 1; color:#0000FF">    
      <input onclick="sureButton()" type="submit" value="确定" name="B1" style="border-style: outset; border-width: 1; color:#0000FF"></td>   
        </tr>   
      </table>   
      </td>   
    </tr>   
    <tr>   
      <td height="20" colspan="3" align="center" style="border:1px solid #000080; ">   
      <marquee behavior="slide" style="color: #808080">::日期格式为年-月-日,直接填入图片和点击路径全名时应仔细查对是否正确::</marquee></td>   
    </tr>   
  </table>   
</div>   
  
</body>   
  
</html> 
分享到:
评论
1 楼 qichunren 2008-02-27  
不错不错!

相关推荐

    js confirm&#40;&#41;方法的使用方法实例

    下面我们通过这两个小例子,来了解一下它的使用方法吧: 代码如下:&lt;html&gt;&lt;head&gt;&lt;title&gt;confrim 的使用方法&lt;/title&gt;[removed]function clear1(){ if(confirm(“确定要清空数

    magik图形用户界面的例子

    最近在学习magik,这是我今天写的一个用户注册的例子,里面包括了,常用的...因为我每次都是使用load_file编译的,它都只是重新覆盖以前的方法,对于以前版本,而现在版本不存在的方法它还是能使用,所以出了点问题。

    Android html5 js css调用测试例子.rar

     继承WebChromeClient类,在这个类的3个方法中,分别使用Android的内置控件重写了Js中对应的对话框,就是说对js中的对话框做处理了,就是重写了。  通过Android调用JS处理alert弹出框 、处理confirm弹出框、处理...

    GUI应用实例-11.rar

    ,包括confirm对话框和modal型图形界面的用法。 shili.rar ,包括了4个很好的例子: (1)具有多个坐标轴的GuI,主要学习控制哪一个坐标轴是绘图命令的对象和用编辑文本框读入输入的数。 (2)...

    GUI应用实例-plotExamples.rar

    ,包括confirm对话框和modal型图形界面的用法。 shili.rar ,包括了4个很好的例子: (1)具有多个坐标轴的GuI,主要学习控制哪一个坐标轴是绘图命令的对象和用编辑文本框读入输入的数。 (2)...

    GUI应用实例-shili.rar

    ,包括confirm对话框和modal型图形界面的用法。 shili.rar ,包括了4个很好的例子: (1)具有多个坐标轴的GuI,主要学习控制哪一个坐标轴是绘图命令的对象和用编辑文本框读入输入的数。 (2)...

    Ajax 仿Windows桌面和开始菜单特效.rar

    支持窗口拖动,Ajax动态加载数据,显示桌面时钟,显示桌面图标、开始菜单等,使用方法:创建一个窗口:AddWin(Aid,Atitle,Aurl,Aw,Ah,Atype,Abut)  Aid -- 唯一ID,不要与其它窗口相同,可以是任意字母数字等  A...

    enhanced-alert:一个 jquery ui 插件

    用法 警报 $.ea.alert&#40;message[,title[,icon]]&#41; 例子: $.ea.alert&#40;"I'm new",'Warning'&#41;; 确认 $.ea.confirm&#40;message[, title[, callback[, icon]]]&#41; 例子: $.ea.confirm&#40;'Are your...

    JS+DIV实现消息提示

    包含方法有: &lt;br&gt;messageBox:function(_width,_height,_title,_message) &lt;br&gt;alertBox:function(_title,_message) &lt;br&gt;confirmBox:function(_title,_message) &lt;br&gt;使用了一些Prototype.js的方法,...

    精通JavaScript

    1.本书附源代码共计381个,其运行环境如下: ...• 14.2.htm alert()方法与confirm()方法的使用 • 14.3.htm prompt()方法的使用 • 14.4.htm window.open()方法 • 14.5.htm ...

    XPYKit:制作ToolsAndCategories的Cocoapods库

    pod 'XPYKit' :git =&gt; ' https :/ / github . com / xiangxiaopenyou / XPYKit . git用法警报 [XPYAlertManager showAlertWithTitle:@"Alert" message:@"Alert" cancel:@"取消" confirm:@"确定" inController:self ...

    精通javascript

    方法与confirm()方法的使用 • 14.3.htm prompt()方法的使用 • 14.4.htm window.open()方法 • 14.5.htm 用链接和按钮实现窗口打开 • 14.6.htm 窗口的打开和关闭 • 14.7....

    angularjs-match-directive:这是一个自定义匹配指令,用于验证两个字段是否相等。 对密码匹配、用户名等有用

    #Angularjs-Match-Directive 作者:安东尼·罗德里格斯。 用于验证两个字段是否相等的自定义匹配指令。... 将match指令属性插入要匹配的元素中,在我们的例子中是: confirmPassword match="pas

    Ext Js权威指南(.zip.001

    6.1.8 ext.domquery的使用方法 / 249 6.1.9 ext js选择器的总结 / 252 6.2 获取单一元素:ext.dom.element / 252 6.2.1 从错误开始 / 252 6.2.2 使用ext.get获取元素 / 253 6.2.3 使用ext.fly获取元素 / 256 ...

    react-native-picker-checkbox:一个带有React-Native复选框列表的简单选择器组件

    内容例子$ cd example$ npm i$ react-native run-ios // For ios$ react-native run-android // For Android安装npm install react-native-picker-checkbox --save 用法 import PickerCheckBox from 'react-native-...

    php-core-validator:表单提交时用于数据验证的表单验证器脚本

    地位安装安装作曲家 curl -sS https://getcomposer.org/installer | php编辑 composer.json {...$_POST 的例子如下: $_POST = array('username' =&gt; "",'password' =&gt; "123456",'confirm_password' =&gt; "125",'fir

    ASP.NET常用代码

    不要使用Response.Redirect,而应该使用Server.Transfer e.g // in global.asax protected void Application_Error(Object sender, EventArgs e) { if (Server.GetLastError() is HttpUnhandledException) Server....

    WAP 无线应用协议

    6.2.2 使用WMLScript的好处 113 6.3 WMLScript的核心 113 6.3.1 词汇结构 113 6.3.2 变量和数据类型 117 6.3.3 运算符和表达式 120 6.3.4 函数 125 6.3.5 语句 127 6.3.6 函数库 131 6.3.7 编译指示 131 6.4 数据...

    js使用小技巧

    " 和 "?"也编码 表格行指示 //各种尺寸 s += " 网页可见区域宽:"+ document.body.clientWidth; s += " 网页可见区域高:"+ document.body.clientHeight; s += " 网页可见区域高:"+ document.body....

Global site tag (gtag.js) - Google Analytics