Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date validation error in #646

Closed
Javiergc opened this issue Feb 20, 2013 · 3 comments
Closed

Date validation error in #646

Javiergc opened this issue Feb 20, 2013 · 3 comments

Comments

@Javiergc
Copy link

Hi, I think I found the next issues with 1.11.0 version:

  • In Firefox 18 are valid dates: with four digits ('3333') and '40/50/2000'
  • In Chrome 24 are not valid dates: '22', '2222222' (seven digits or more)... but '11', '222', '2222' are taken as valid...
  • In Explorer 9 is valid the date: '40/50/2000' but correctly taken as not valid the others.

I tried with version 1.10 and older JQuery.

Code:


<title>InformaticaPC | Validar formularios con JQuery</title>
<script type="text/javascript" src="../lib/jquery-1.9.1.js"></script>

<script type="text/javascript" src="jquery.validate.js"></script>


<script type="text/javascript">

    $(document).ready(function()
    {

        $('#form1').validate({
            rules: {
                'txtFNac': { required:true, date:true }
                },
            messages: {
                'txtFNac': { required:'Write the date', date:'not valid' }
            }

        });

    });

</script>
  <div id="log">&nbsp;</div>

  <form name="form1" id="form1" method="post" action="#">

      <label for="txtFNac">F/nac (*):</label>
      <input type="text" name="txtFNac" id="txtFNac" /><br />

      <input type="submit" name="btnEnviar" id="btnEnviar" value="Enviar &gt;&gt;" />

  </form>

Maybe there's something wrong ?

@tan00001
Copy link

jquery.validation.js relies on "new Date(value)" to validate dates. But for IE 9,e.g., new Date('15/45/2333') actually returns a date successfully. So the result of validation becomes bugus.

@jzaefferer
Copy link
Collaborator

The date method is broken and shouldn't be used anymore. There are a few alternatives like dateISO and country specific methods. Eventually this will be adressed by #581, but I don't see any shortterm fix for the current date method.

@jzaefferer
Copy link
Collaborator

I also made a note about that on the docs for that method: http://docs.jquery.com/Plugins/Validation/Methods/date

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants