日期选择器验证18岁 [英] Datepicker validation 18 years of age
问题描述
我使用的是twitter bootstrap中的日期选择器,并且我想添加一些验证,如果您的日期未满18周岁,您的注册将不会被视为已注册,那么我该怎么做?这里是我的出生日期的示例html代码:
< label>出生日期*< / label>
< input type =datename =birth_datetabindex =7style =height:30px;所需>
如果您向下看演示页面,会看到一个限制日期选择器部分。
$(#restrictting)使用下拉菜单指定年份下拉菜单显示过去20年演示).datepicker({
yearRange:-20:+0,//这是您正在查找的选项
showOn:both,
buttonImage:templates / images / calendar.gif,
buttonImageOnly:true
});
您也会想要做同样的事情(显然会将-20改变为-100或其他值) / p>
或者您可以使用
$('#dp1')。 datepicker({
格式:'mm-dd-yyyy',
startDate:'-15d',
endDate:'+ 0d'//没有方便的现在记号
});
I am using a date picker from twitter bootstrap and I want to add some validation that your sign up will not suppose to be registered once your date is below 18 years of age, how am I supposed to do that? here is my sample html code for the birthdate:
<label>Date of Birth*</label>
<input type="date" name="birth_date" tabindex="7" style="height: 30px;" required>
If you look down the demo page a bit, you'll see a "Restricting Datepicker" section. Use the dropdown to specify the "Year dropdown shows last 20 years" demo , and hit view source:
$("#restricting").datepicker({
yearRange: "-20:+0", // this is the option you're looking for
showOn: "both",
buttonImage: "templates/images/calendar.gif",
buttonImageOnly: true
});
You'll want to do the same (obviously changing -20 to -100 or something).
Or you can use
$('#dp1').datepicker({
format: 'mm-dd-yyyy',
startDate: '-15d',
endDate: '+0d' // there's no convenient "right now" notation yet
});
这篇关于日期选择器验证18岁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!