on 07-18-2022 12:41 PM
Hi everyone,
I'm trying to implement a m.Input, which only allows inputs in the hh:mm format. I searched the properties but there is no such default option.
TimePicker is no option, because the input should not be limited to 24:00h
So I was wondering if someone has a solution, how I can implement this. I was thinking about some kind of regex implementation.
An additional validation function could be a possible solution, but I find it much cleaner to implement this in a way, that only valid data can be typed in.
Thank you!
Marcel
How about using sap.m.MaskInput ?
<MaskInput mask="HH:Mm" placeholderSymbol="_" placeholder="Enter a time" >
<rules>
<MaskInputRule maskFormatSymbol="H" regex="[0-9]"/>
<MaskInputRule maskFormatSymbol="M" regex="[0-5]"/>
<MaskInputRule maskFormatSymbol="m" regex="[0-9]"/>
</rules>
</MaskInput>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
Apart from Gábor Márián solution, Additional option may be
var dt = new sap.m.Input({
change : function() {
var isValid = /^([0-1]?[0-9]|2[0-4]):([0-5][0-9])(:[0-5][0-9])?$/.test(this.getValue());
if (isValid)
{ alert("valid Time format"); }
else
{ alert("Invalid Time format");}
}
});
Regards,
Venkat
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.