How to Clear Input using the validator.AddMethod

0

I'm using this code below to validate a date field.

$.validator.addMethod("formatoData",
       function (value, element) {
           var reg = /^(((0[1-9]|[12]\d|3[01])\/(0[13578]|1[02])\/((19|[2-9]\d)\d{2}))|((0[1-9]|[12]\d|30)\/(0[13456789]|1[012])\/((19|[2-9]\d)\d{2}))|((0[1-9]|1\d|2[0-8])\/02\/((19|[2-9]\d)\d{2}))|(29\/02\/((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))))$/g;
           return reg.test(value)
       },
       "Por favor digite uma data válida");

I wanted to make sure that when the alert is displayed it clears the value that was typed in the input, I tried to do it as follows.

"Por favor digite uma data válida" + $('[name="dtahosp"]').val(''));

I just did not succeed. Can someone give me some help?

    
asked by anonymous 26.04.2018 / 17:29

0 answers