1

Im just wondering if Im using them wrongly or there are some serious issues about those validations available online.

Example of one of many sites using jquery validation

I entered "44" for name, and i see no warning! For email i use ##@yahoo.com, again no warning!

I didn't try other. My question is, Im I wrong? whats the best way to proceed with Client side validation?

<form class="cmxform" id="commentForm" method="get" action="">
  <fieldset>
    // fields to be validated
  </fieldset>
</form>
<script>
  $("#commentForm").validate();
</script>

@Mahesh your demo too gives same results. I used ##@44.com for email and 55 for name. No warning. what i really want to know is, are those validations normal?

Randy Geily
  • 141
  • 1
  • 2
  • 12

3 Answers3

1
<form id="myform">
<label for="field">Username: </label>
<input class="left" id="username" name="username">
<br/>
    <label for="field">Email: </label>
<input class="left" id="email" name="email">
<br/>
    <input type="submit" value="Validate!"/>
</form>



// just for the demos, avoids form submit
jQuery.validator.setDefaults({
  debug: true,
  success: "valid"
});
$( "#myform" ).validate({
  rules: {
    username: {
      required: true
    },
      email : {
          required: true,
          email : true
      }
  }
});

DEMO

msapkal
  • 8,268
  • 2
  • 31
  • 48
0

In your code there is only a textarea. No email and no name. To validate an email use

<p>
    <label for="cemail">E-Mail (required)</label>
    <input id="cemail" type="email" name="email" required />
</p>
Andynedine
  • 441
  • 5
  • 20
0

it is simple: for Email validation:

 function IsEmail(email) {
        var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
        return regex.test(email);
 } // returns True if email is correct formatted
ADAD.TJ
  • 63
  • 8