如何检测用户是否从html输入日期中选择了日期[关闭]
i am new to html and p-h-p. what i am looking for is that i have provided user an input date calendar through html date input method. Now how can i detect that user have provided date or not ... if he didn't selected date from calendar he should be get an alert to please provide date... the problem i'm facing is if user is not selecting a date so the value of "date-from" which is the "value" of input date is setting to default date automatically. by default i mean least date. i should be very much thankful if anyone can help ...
我是html和p-h-p的新手。 我正在寻找的是我通过html日期输入法为用户提供了一个输入日期日历。 如何检测到该用户是否提供了日期...如果他没有从日历中选择日期他应该得到 请提供日期的警告...... 我面临的问题是,如果用户没有选择日期,那么“date-from”的值(输入日期的“值”)将自动设置为默认日期。 ,默认我的意思是最短的约会。 i应该非常感谢,如果有人可以提供帮助...... p> div>
Why can't we just use the HTML5 required?
<input type="date" name="date" required>
I would suggest you used JavaScript for this purpose instead. By doing that you will be able to keep it client sided and the user don't have to refresh the page to validate.
Pls have a look at "onblur" event or just "onsubmit" in JavaScript