This time I will bring you input[type='date'] custom style and calendar verification function, input[type='date'] custom style and calendar verification Notes What are they? Here are actual cases. Let’s take a look.
1. Calendar control custom style
HTML5 provides the calendar control function, which reduces development time, but sometimes its style is indeed not as good as As you like, we can modify it ourselves according to the code below.
Suggestion: Copy the code snippet below and create a separate css file for our convenience.
/* 修改日历控件类型 */ ::-webkit-datetime-edit { padding: 1px;} /*控制编辑区域的*/ ::-webkit-datetime-edit-fields-wrapper { background-color: #fff; } /*控制年月日这个区域的*/ ::-webkit-datetime-edit-text { color: #333; padding: 0 .5em; } /*这是控制年月日之间的斜线或短横线的*/ ::-webkit-datetime-edit-year-field { color: #333; } /*控制年文字, 如2013四个字母占据的那片地方*/ ::-webkit-datetime-edit-month-field { color: #333; } /*控制月份*/ ::-webkit-datetime-edit-day-field { color: #333; } /*控制具体日子*/ ::-webkit-inner-spin-button { visibility: hidden; } /*这是控制上下小箭头的*/ ::-webkit-calendar-picker-indicator { /*这是控制下拉小箭头的*/ border: 1px solid #ccc; border-radius: 2px; box-shadow: inset 0 1px #fff, 0 1px #eee; background-color: #eee; background-image: -webkit-linear-gradient(top, #f0f0f0, #e6e6e6); color: #666; } ::-webkit-clear-button { /*控制清除按钮*/ }
2. Date verification function
The end date cannot be less than the start date, the date selection range is 7 days, and the remaining time periods are Not optional.
Note: The following code snippet uses Jquery principle
//转换时间类型为 yyyy-mm-dd function FormatDate (strTime) { var date = new Date(strTime); var formatedMonth = ("0" + (date.getMonth() + 1)).slice(-2); var formatedDate = ("0" + (date.getDate())).slice(-2); return date.getFullYear()+"-"+formatedMonth+"-"+formatedDate; } //开始时间 $("#keyword_time_min").change(function(){ var d1=new Date($(this).val()); //获取当前时间 var d2=new Date(d1); // d2.setFullYear(d2.getFullYear()+1); //当前时间+1年 d2.setDate(d2.getDate()+7); //当前时间+7天 d2=FormatDate(d2); //转换d2为YYYY-MM-DD格式 $("#keyword_time_max").attr("max",d2); //最大时间为d2 $("#keyword_time_max").attr("min",$(this).val()); //最小时间为当前时间 }); //终止时间 $("#keyword_time_max").change(function(){ var d3=new Date($(this).val()); var d4=new Date(d3); // d4.setFullYear(d4.getFullYear()-1); d4.setDate(d4.getDate()-7); //当前时间-7天 d4=FormatDate(d4); $("#keyword_time_min").attr("min",d4); $("#keyword_time_min").attr("max",$(this).val()); });
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!
Recommended reading:
Detailed explanation of the use of History mode in H5
The above is the detailed content of input[type='date'] custom style and calendar verification function. For more information, please follow other related articles on the PHP Chinese website!

如果您正在寻找根据系统时间戳自动创建文件和文件夹并为其命名的方法,那么您来对地方了。有一种超级简单的方法可以用来完成这项任务。然后,创建的文件夹或文件可用于各种目的,例如存储文件备份、根据日期对文件进行排序等。在本文中,我们将通过一些非常简单的步骤解释如何在Windows11/10中自动创建文件和文件夹,并根据系统的时间戳对其进行命名。使用的方法是批处理脚本,非常简单。希望你喜欢阅读这篇文章。第1节:如何根据系统当前时间戳自动创建文件夹并命名第1步:首先,导航到要在其中创建文件夹的父文件夹,

在使用PHP程序开发时,经常会碰到一些警告或者错误的提示信息。其中,可能出现的一个错误提示就是:PHPWarning:date()expectsparameter2tobelong,stringgiven。这个错误的提示信息意思是:函数date()的第二个参数期望是长整型(long),但是实际传递给它的是字符串(string)。那么,我们

Go中Type关键字的用法有定义新的类型别名或者创建新的结构体类型。详细介绍:1、类型别名,使用“type”关键字可以为已有的类型创建别名,这种别名不会创建新的类型,只是为已有的类型提供一个新的名称,类型别名可以提高代码的可读性,使代码更加清晰;2、结构体类型,使用“type”关键字可以创建新的结构体类型,结构体是一种复合类型,可以用于定义包含多个字段的自定义类型等等。

ubuntu挂载移动硬盘出现错误:mount:unknownfilesystemtype'exfat'处理方法如下:Ubuntu13.10或安装exfat-fuse:sudoapt-getinstallexfat-fuseUbuntu13.04或以下sudoapt-add-repositoryppa:relan/exfatsudoapt-getupdatesudoapt-getinstallfuse-exfatCentOSLinux挂载exfat格式u盘错误的解决方法CentOS中加载extfa

laravel input隐藏域的实现方法:1、找到并打开Blade模板文件;2、在Blade模板中使用method_field方法来创建隐藏域,其创建语法是“{{ method_field('DELETE') }}”。

准备工作用vuecreateexample创建项目,参数大概如下:用原生input原生的input,主要是value和change,数据在change的时候需要同步。App.tsx如下:import{ref}from'vue';exportdefault{setup(){//username就是数据constusername=ref('张三');//输入框变化的时候,同步数据constonInput=;return()=>({

一.介绍java.util包中的Date类表示特定的时间,精确到毫秒。如果要想使用我们的Date类,那么我们必须得引入我们的Date类。Date类直接写入年份是得不到正确的结果的。因为java中Date是从1900年开始算的,所以前面的第一个参数只要填入从1900年后过了多少年就是你想要得到的年份。月需要减1,日可以直接插入。这种方法用的比较少,常用的是第二种方法。这种方法是将一个符合特定格式,比如yyyy-MM-dd,的字符串转化成为Date类型的数据。首先,定义一个Date类型的对象Date

Python中有许多优秀的日历库和日期库供我们使用,这些库可以帮助我们处理日期和日历相关的操作。接下来,我将为大家介绍几个常用的选择,并提供相应的代码示例。datetime库:datetime是Python内置的日期和时间处理模块,提供了许多日期和时间相关的类和方法,可以用于处理日期、时间、时间差等操作。示例代码:importdatetime#获取当


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Atom editor mac version download
The most popular open source editor
