`

confirm用法和例子

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

无论确定还是否它都会往下继续执行,除非其嵌套的内容执行了return

confirm('真的要删除吗?删除后将无法恢复!'){
    ……


例子:
<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>
<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>
</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;">&nbsp;
              <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;">&nbsp;
              <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%" >&nbsp;
              <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">&nbsp;
      <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>




分享到:
评论

相关推荐

    jquery confirm漂亮的例子

    在标题和描述中提到的“jquery confirm漂亮的例子”,我们将深入探讨这个主题,展示如何使用jQuery Confirm来创建吸引人的对话框,并了解其主要功能和用法。 首先,引入jQuery和jQuery Confirm库。在HTML文件中,你...

    alert和confirm弹出框样式美化

    首先,我们不再直接使用`window.alert()`和`window.confirm()`方法,而是创建自定义的HTML结构来模拟这些对话框。创建一个包含消息内容、按钮等元素的模态框(modal),并将其隐藏,当需要弹出时通过JavaScript显示...

    jquery-confirm设置按钮显示中文

    在引入jQuery和jquery-confirm插件后,我们可以使用$.confirm()方法来创建一个对话框。例如: ```javascript $.confirm({ title: '确认操作', content: '你确定要删除这个文件吗?', buttons: { 确认: function...

    自制confirm弹出框

    在网页开发中,为了增强用户体验和交互性,我们经常需要使用到各种弹出框,如确认对话框(Confirm)、警告对话框(Alert)以及自定义的弹出框。本示例主要关注的是“自制confirm弹出框”,这是一种自定义的删除确认...

    confirm

    在JavaScript编程中,"confirm"是一个内置函数,用于创建一个对话框向用户显示消息,并提供“确定”和“取消”两个按钮供用户选择。这个功能常用于需要用户确认执行某个操作的情况,比如删除数据或者退出应用。在...

    jquery-confirm

    使用`jquery-confirm`的方法很简单,首先需要在页面中引入jQuery库和`jquery-confirm`的CSS和JS文件,然后通过jQuery选择器调用`.confirm()`方法,即可创建一个确认对话框。例如: ```html &lt;!DOCTYPE html&gt; ...

    前端项目-angular-confirm.zip

    4. **调用方法**:使用服务提供的 `confirm` 方法显示确认模态,并提供回调函数来处理用户选择。 5. **配置模态**:可以通过选项参数来配置模态的外观和行为。 ### 示例代码 ```typescript import { Component } ...

    在Android的webview中定制js的alert,confirm和prompt对话框的方法

    在 Android 的 WebView 中定制 JS 的 Alert、Confirm 和 Prompt 对话框的方法 在 Android 中,使用 WebView 来加载网页时,会遇到 JavaScript 的 Alert、Confirm 和 Prompt 对话框的问题。这些对话框是浏览器默认的...

    alert和confirm和ng-repeat

    在本话题中,我们将深入探讨如何结合Bootstrap的`alert`和`confirm`功能,以及如何在其中使用`ng-repeat`进行双层嵌套。 首先,Bootstrap是Twitter开发的一个开源CSS框架,提供了丰富的组件和样式,如模态框、警告...

    模态子窗口alert confirm 弹窗

    要注意,具体的使用方法需要参考LoFzeModal的文档,因为每个库都有自己的API和用法。 总的来说,模态子窗口在网页交互中扮演着重要角色,Alert和Confirm提供了基本的弹窗功能,而自定义模态库如LoFzeModal则允许...

    如何判断Confirm消息框中哪个按钮被单击了

    在JavaScript编程中,`confirm()`函数是一个内置的对话框,用于向用户显示一个带有确定(OK)和取消(Cancel)两个按钮的消息框。这个对话框会暂停程序的执行,直到用户点击其中一个按钮。当你需要用户确认某个操作...

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

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

    layer.js用法例子

    在本文中,我们将深入探讨`layer.js`的使用方法,帮助开发者更好地理解和应用这个工具。 ### 1. 安装与引入 首先,你需要下载`layer.js`文件,将其放在项目目录中,并通过HTML中的`&lt;script&gt;`标签引入。例如: ```...

    JQuery Alert、confirm、prompt提示框插件.zip

    3. **初始化插件**:在文档加载完成后,使用$(document).ready()方法初始化插件,根据插件文档配置相应的选项。 4. **使用插件**:在需要弹出提示框的地方,使用插件提供的函数替换原生的alert(), confirm(), 或 ...

    JavaScript常用的窗口函数(showModalDialog,open,confirm)

    标题提到的"JavaScript常用的窗口函数"主要包括`showModalDialog`、`open`和`confirm`,它们都是与浏览器窗口操作相关的函数,用于实现不同类型的用户交互。下面将详细阐述这三个函数的功能、用法及其在实际开发中的...

    修改js confirm alert 提示框文字的简单实例

    在JavaScript中,`alert`、`confirm`和`prompt`是内置的对话框函数,用于向用户显示消息或请求输入。这些对话框是浏览器提供的原生功能,它们的外观和行为通常不能直接自定义,但我们可以创建自定义的模态窗口来模拟...

    js确认框confirm&#40;&#41;用法实例详解

    JavaScript中的`confirm()`函数是一个内置的弹窗函数,用于创建一个带有“确定”和“取消”按钮的对话框,通常用于用户确认操作。本文将详细介绍`confirm()`的三种常见用法,并通过实例进行解析。 ### 第一种方法 ...

    解决layer.confirm快速点击会重复触发事件的问题

    `layer.confirm`是layui框架中提供的一个功能,用于创建带有确认和取消按钮的弹窗。在默认情况下,它并不阻止事件的连续触发,这就可能导致用户在弹窗显示期间快速点击按钮,从而触发事件的多次执行。 **问题分析**...

    AsyncBox例子

    总的来说,"AsyncBox例子"是一个学习如何在网页中使用jQuery弹窗插件的实战案例,涵盖了前端开发中的DOM操作、事件处理、Ajax通信、动画效果等多个方面。通过深入研究提供的源代码,开发者可以提升自己的技能,并将...

    jQuery表单验证例子(demo)

    在表单验证场景中,jQuery Validate插件是jQuery生态系统中的一个重要组成部分,它提供了一套完整的规则和方法来确保用户输入的数据符合预设的格式和要求。 jQuery Validate插件的核心在于其易于理解和使用的API。...

Global site tag (gtag.js) - Google Analytics