[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 433
  • Last Modified:

JQuery - Form Validation

Is it possible to get an example (not link please) for a one field form JQuery validation, including necessary plugin links?

Just basic as can be saying field is required.

0
carsRST
Asked:
carsRST
2 Solutions
 
leakim971PluritechnicianCommented:
with :

<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.js"></script>

test page : http://jsfiddle.net/92BPm/

$(document).ready(function() {
    $("form").validate();
})

Open in new window

<form action="http://www.google.gp" method="get">
    <input type="email" class="required email" />
    <br />
    <input type="submit" value="Submit" />
</form>

Open in new window

0
 
sonawanekiranCommented:
Here is validation of different types of form element
<head>
<meta http-equiv="Content-Language" content="en-gb">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Kiran Test</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>
  <script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.js"></script>
<script>
$(document).ready(function(){
  $("#registerForm").validate({
    rules: {
      email: "required",
      name: "required",
      title: "required",
      checkme: {
        required: function(element){
          return !$("#checkme").is(':checked');
        }
      },
    }
  });
});
</script>

</head>

<body>
<form method="POST" id="registerForm" >
  <table>
       <tr>
       <td><input name="email" type="email"></td>
       </tr>
       <tr>
         <td>
        <select size="1" value="" name="title">
        <option selected></option>
        <option value="mr">mr</option>
        <option value="mrs">mrs</option>
        <option value="ms">ms</option>
        <option value="miss">miss
        </option>
        </select></td>
       </tr>
       <tr>
         <input name="name">
       </tr>
       <tr>
        <td>Check Me <input name="checkme" type="checkbox" id="checkme"></td>
      </tr>
  </table>
      

<p><input type="submit" value="submit"><input type="reset" value="clear form"> </p>
</form>
</body>

</html>

Open in new window

0
 
carsRSTAuthor Commented:
Thank you!

Exactly what I wanted.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now