In reactive I have a input with type date. When typing a date, it is possible to type 6 characters for the year.
Someone know how to solve this issue?
Thx
Hi Lander,
At least in Chrome, it works when setting the max date to something with four years:
I can then type in only four digits for the year.
Wow so easy (if you know it) :-)
Big Thanks
Glad I could be of help!
In case someone (like myself) stumbles across this in the future: for a DateTime field you can use max="9999-12-31T23:59", instead.
Thanks for sharing
Hi Briliant solution, thanks.But I have issue with year limitI thought max = "2100-12-31" will work, but I still can enter any number >= 9999Looking for anykind of suggestion or advice :-)Best Regards
Sera)
Hello Lander De Wulf,
I supposed that you are using an input with a variable type Date, right? That is the default behaviour from the browser.
You can use Javascript, to remove the extra numbers after you insert more then 4, but if you made a "long press" on a number you will see for some seconds the all numbers before the Javascript erase the value.
Best Regards,
Nuno R
You can limit the input length using Jquery.don't forget to add this script to your libraries and reuse it instead of add it directly to your WB or Screen:
The input parameter of the script should be your input name and it should look something like this:
//Script stat ################
var max_chars = 10; //Max Characters number
$('#" + YourInputName.Id + "').keydown( function(e){
if ($(this).val().length >= max_chars) {
$(this).val($(this).val().substr(0, max_chars));
}
});
$('#" + YourInputName.Id + "').keyup( function(e){
//Script End ################
Note: you need to replace YourInputName, with your actual Input name (give it a name if it has not one already)
You can also define another script input parameter and replace the number of characters into a dynamic way to reused it in the future to other different lenght inputs that you want to limit.
Cheers,
JS.
I think the solution presented by Kilian Hekhuis, is nice, a have tried on other recent browsers and work. The one presented by José Santos, I think will work also but is better to convert to vanilla JS, because we don't need jQuery.
@Kilian Hekhuis
thank you its working.