是否可以知道输入类型= datetime-local是否填满了一半? [英] Is it possible to know if an input type = datetime-local is halfway filled?

查看:128
本文介绍了是否可以知道输入类型= datetime-local是否填满了一半?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以知道输入类型= datetime-local是否中途填满?例如,是否仅填写日期或时间?

Is it possible to know if an input type = datetime-local is halfway filled? For example, if only the date or time is filled?

<input type="datetime-local" class="form-control input-lg" id="dueDate" 
ng-model="jobDueDate" min="{{currentMin | date:'yyyy-MM-ddTHH:mm'}}" 
placeholder="Due Date" >

输入标签的元素对象值是空的,无论它是空的还是中间填充的.

The element object value of the input tag is empty no matter if it is empty or halfway filled.

var valuedate = document.getElementById('dueDate');
console.log(valuedate.value());

Date.parse在两种情况下也都返回NaN.有没有可能的解决方案?我正在使用Jquery& AngularJS如果有帮助的话.随时使用其他输入类型发布清洁器解决方案(无需额外的库).目的是让用户填写两个字段.

Date.parse returns NaN as well for both cases. Is there a possible solution? I'm using Jquery & AngularJS if those could help. Feel free to post cleaner solutions using other input types (no extra libraries). The aim is for the user to fill both fields out.

字段可以保留为空白或完全填充.我需要知道它是否已满一半,以便我可以提示用户或自己计算所需的日期.

Field can either be left blank or fully filled. I need to know if it's half filled so I can prompt the user or calculate the required date myself.

推荐答案

您可以通过以下方法检测半填充字段:

You can detect half-filled field by:

document.querySelector('#dueDate').validity.badInput

这篇关于是否可以知道输入类型= datetime-local是否填满了一半?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆