Validate the date format

Validate the date format

klermannklermann Posts: 277Questions: 67Answers: 1
edited September 2017 in Free community support

How can Ivalidate the date format here here? I'm trying like this:

editor.on( 'preSubmit', function ( e, o, action ) {
          if(!dataReceita.format: "DD/MM/YYYY"){
        dataReceita.error("Insira uma data válida!");
            }
                                              
         }
     } );

Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • Tester2017Tester2017 Posts: 145Questions: 23Answers: 17

    What you need is some kind of regex validation, as I think is (still) not available in DataTables.I don't know if you are using some kind of framework like i.e. Codeigniter. I don't use the validation of Datatables, but my own ones (in this case with Codeigniter).

    Maybe I am totally wrong as I am new to Datatables also.

    Receiving an Ajax request I check the $_POST for the kind of operation; read, update, insert or delete. In case of an insert or update I call form my own validation rules. This more or less how I am trying to resolve my issues. Quando precisa mais detalhes posse lhe dar. I am speaking Portuguese also ;)

  • Tester2017Tester2017 Posts: 145Questions: 23Answers: 17

    Forget my answer as you were asking for a pre-submit validation.

  • allanallan Posts: 63,471Questions: 1Answers: 10,467 Site admin

    I would suggest you use MomentJS's isValid() function.

    Allan

This discussion has been closed.