Problem with Data Lock datatable editor

Asked

Viewed 26 times

0

{
        label: "Data Nascimento:",
        name: "Cliente.DataNasc",
        type:   "datetime",
        format: 'DD/MM/YYYY',
        def:    function () { return new Date(); },
        attr:   { autocomplete: "off" }
    },

I need to put a range of 100 years counting today back, ex: people over 100 years can not register. And I need to block a specific date 01/01/1900

  • You need to provide more details of your problem. What the problem itself, what instruction it occurs in, etc. Detail it so we can help you.

  • Does not answer your own question. Put the update in the question itself to keep the organization. In addition to showing the json with the information, add the HTML snippet where it is will be inserted.

  • Already corrected, thank you

1 answer

0

When building an object with new Date(), you can enter 3 parameters: year, month (starting with 0) and day).

Maybe, in your case, you could wear something like this:

const hoje = new Date();
let menosCemAnos = new Date(hoje.getYear() -100, hoje.getMonth(), hoje.getDate());

Then you will have the following exits:

hoje.toString() // "Wed May 08 2019 18:18:17 GMT-0300 (Horário Padrão de Brasília)"
menosCemAnos.toString() //"Thu May 08 1919 00:00:00 GMT-0300 (Horário Padrão de Brasília)"

Obviously, to create a certain date: new Date(1900,0,1)

I hope it helps.

  • But how to apply this case in datatable editor:?

  • I don’t know the component you mention, but as a rule it must have some property where you set the date you want as a starting point, or properties that define start and end date.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.