-1

I am new to jQuery validation but have tried a number of things and none work.

Issue trying to get an e-mail to validate.

This ColdFusion code works great:

<li>
    <label>Accounts Email</label>
    <input name="AccountsEmail" id="AccountsEmail"  type="email" maxlength="100"  size="35" value="#Licencee.getaccountsemail()#" />
    <cfif len(licencee.getaccountsemail()) GT 0>
        <a href="mailto:#Licencee.getaccountsemail()#" class="uk-icon-envelope-o"></a>
    </cfif>
</li>
<li></li>

The above code puts a symbol which is a link when there is an e-mail address, but we want to test a correctly formatted e-mail address has been entered.

<script>
    $("#licenceeForm").validate();
</script>  

This tests the address great.

This issue we have is changing the error message. I just want to change the field to red no message just do not let the user out unless the e-mail is correctly formatted OR blank.

I tried this:

$( "#licenceeForm" ).validate({
    rules: {
        AccountsEmail: {
            required: false,
            email: true
        }
    }
});

but that resulted in no difference

I have tried:

jQuery.extend(jQuery.validator.messages, {
    required: "This field is required.",
    remote: "Please fix this field.",
    email: "Inc.",
    min: jQuery.validator.format("Please enter a value greater than or equal to {0}.")
});

This changed the message but it was still a message and the message changes the layouts and the resultant screen does not look good.

Miguel-F
  • 13,450
  • 6
  • 38
  • 63

1 Answers1

-1

Try this

$( "#licenceeForm" ).validate({
  rules: {
    name: "required",
    email: {
      required: true,
      email: true
    }
  },
 errorPlacement: function(error, element) {
    error.hide();
  }
});

And if you want to custom the input when there is an error try this :

Js

$( "#licenceeForm" ).validate({
      rules: {
        name: "required",
        email: {
          required: true,
          email: true
        }
      },
     errorPlacement: function(error, element) {
        error.hide();
      },
    errorClass: "invalid" // customize your input when there is an error, remove this line if you just like the basic
    });

EXAMPLE : JSFIDDLE

Bidoubiwa
  • 910
  • 2
  • 12
  • 25