[Custom Input Masks] Questão - IsValid

Forge Component
(43)
Published on 2019-04-22 by Marcelo Ferreira
43 votes
Published on 2019-04-22 by Marcelo Ferreira

Na função OSCustomMasks_MaskDate esta linha :

Inputmask.isValid(value, { alias: maskFormat})


Isto está correto ? Estive a ver na documentação  e está assim :

var isValid = Inputmask.isValid("23/03/1973", { alias: "datetime", inputFormat: "dd/mm/yyyy"});

Hi Filipe,


"With an alias you can define a complex mask definition and call it by using an alias name. So this is mainly to simplify the use of your masks. Some aliases found in the extensions are: email, currency, decimal, integer, date, datetime, dd/mm/yyyy, etc."

https://github.com/RobinHerbots/Inputmask#aliases


with this definition, I think it's correct


Regards

Pedro Costa wrote:

Hi Filipe,


"With an alias you can define a complex mask definition and call it by using an alias name. So this is mainly to simplify the use of your masks. Some aliases found in the extensions are: email, currency, decimal, integer, date, datetime, dd/mm/yyyy, etc."

https://github.com/RobinHerbots/Inputmask#aliases


with this definition, I think it's correct


Regards

I must be doing something wrong then because:

value = 01-10-2019

Inputmask.isValid(value, { alias: 'datetime', inputFormat:  'dd-mm-yyyy'})

returns true

And 

SyntaxEditor Code Snippet

Inputmask.isValid(value, { alias: 'dd-mm-yyyy'})

Returns false

What am i doing wrong ?

I think you're not doing anything wrong, maybe don't exist the alias 'dd-mm-yyyy' for dates.


If you use MaskText server action with this definition '99-99-9999' instead of MaxDate, what's the result of IsValid function ?

I've been reading the documentation and doing some tests, and it looks like the correct thing would be this:


var isValid = Inputmask.isValid(value, { alias: "datetime", inputFormat: maskFormat});