How to take Month and Year as input ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How to take Month and Year as input ?

Hi! I can take input of month and year in separate input fields but I wants to take input of Month And Year using one input field. How can I achieve that ?? Can anyone please help me ??

3rd Aug 2021, 2:18 PM
Sasuke
15 Answers
+ 2
3rd Aug 2021, 2:23 PM
Pariket Thakur
Pariket Thakur - avatar
+ 1
<input type="month"> <input type="date" >
3rd Aug 2021, 2:20 PM
Pariket Thakur
Pariket Thakur - avatar
3rd Aug 2021, 2:37 PM
Pariket Thakur
Pariket Thakur - avatar
+ 1
Sasuke, Perhaps in case of Firefox, which as you said (confirmed by HrCoder's link) month input is not supported; you can resort to using a simple <select> with option values representing month index. Pretty sure any browser supports that.
3rd Aug 2021, 3:57 PM
Ipang
+ 1
Ipang Thanks Great suggestion But how will I input year
3rd Aug 2021, 4:02 PM
Sasuke
+ 1
Sasuke, As I see it, the date input is supported by Firefox. So there shouldn't be any problem right? besides, date input also supports the month value. But in case there is a problem, I guess you can use number input, with additional validator, just to be sure the entered year wasn't a floating point value e.g. 2021.8 or the likes.
3rd Aug 2021, 4:09 PM
Ipang
0
HrCoder I have tried But not working It is just input type text
3rd Aug 2021, 2:21 PM
Sasuke
0
HrCoder This is working here But not in firefox
3rd Aug 2021, 2:29 PM
Sasuke
0
HrCoder Sorry! But I already told you that is not working in firefox
3rd Aug 2021, 2:59 PM
Sasuke
0
Sasuke that is what i want to say Input type = month is not supported on Firefox
3rd Aug 2021, 3:02 PM
Pariket Thakur
Pariket Thakur - avatar
0
HrCoder Thank you very much. I understand. But do you now any other way to achieve that ? Which work on all browsers I will be grateful to you
3rd Aug 2021, 3:03 PM
Sasuke
5th Aug 2021, 1:38 AM
Abhishek Kumar
Abhishek Kumar - avatar
0
<input type="date"> <input type="month"> <input type="year">
5th Aug 2021, 7:53 AM
Kevin Kogo
Kevin Kogo - avatar
0
Hello
5th Aug 2021, 12:26 PM
Chetan Sharma
Chetan Sharma - avatar
- 1
.
5th Aug 2021, 8:31 AM
Mr Coder
Mr Coder - avatar