jQuery validation plugin: 'required' not working

jQuery validation plugin: 'required' not working

So I've downloaded the jquery validation plugin ( http://jqueryvalidation.org/) but the ability to make a field 'required' doesnt work. Or rather, it only works half. If I make a field required and I click on it and then click away it properly makes the field red as if to show that it needs to be filled in. But if I click submit it doesnt give an error message, which it should. Which is completely weird because for the 'minlength' validation rule it works fine on submit.

Here's the html for the field (ofc I have done all the necessary steps like make a script tag for the validate plugin etc):
  1.      <input type="email" required />

And here's the jquery for the submit, there's some custom jquery in there that cleares the fields with defaultvalues in them, because some of my fields have defaultvalues:

  1.  $("input[type=submit]").click(function(event)
        {
        var $thisform = $($(this).parents('form:first'));
        var $validator = $thisform.validate();
        
            console.log($input.length);
            $input.each(function()
            {
                console.log(this, $validator.element(this));
                if ($(this).css('color') == 'rgb(136, 136, 136)')
                {
                    this.value = '';
                }
            });
            
            
            $validator.form();    
        });
















note: even before I cleared the defaultvalues using this custom submit the code for the required rule still didnt work. The code for minlength, which was my only other used rule worked perfect under all circumstances.




    • Topic Participants

    • hasse