jQuery required validation

<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript" 
src="http://jzaefferer.github.com/jquery-validation/jquery.validate.js"></script>
<script type="text/javascript">
jQuery.validator.setDefaults({
	debug: true,
	success: "valid"
});;
</script>

  <script>
  $(document).ready(function(){
    $("#myform").validate({
  rules: {
    fruit: "required"
  }
});
  });
  </script>
  <style>#fruit { margin-left: .5em; float: left; }
  	#fruit, label { float: left; font-family: Arial, Helvetica, sans-serif; font-size: small; }
	br { clear: both; }
	input, select { border: 1px solid black; margin-bottom: .5em;  }
	select.error { border: 1px solid red; }
	label.error {
		background: url('http://dev.jquery.com/view/trunk/plugins/validate/demo/images/unchecked.gif') no-repeat;
		padding-left: 16px;
		margin-left: .3em;
	}
	label.valid {
		background: url('http://dev.jquery.com/view/trunk/plugins/validate/demo/images/checked.gif') no-repeat;
		display: block;
		width: 16px;
		height: 16px;
	}
</style>
</head>
<body>

<form id="myform">
  <label for="fruit">Please select a fruit</label>
  <select id="fruit" name="fruit" title="Please select something!"
    <option value=""></option>
    <option value="1">Banana</option>
    <option value="2">Apple</option>
    <option value="3">Peach</option>
  </select>
  <br/>
  <input type="submit" value="Validate!" />
</form>

</body>
</html>

you can use this for any input validation.
Its very easy...use it,,,,,,!!!!!!!!!!!!!1111
Advertisements

6 thoughts on “jQuery required validation

  1. You could certainly see your enthusiasm in the article you write.

    The sector hopes for even more passionate writers such as you who
    are not afraid to say how they believe. At all times follow your
    heart.

  2. This is the perfect website for anyone who would like to find out about this topic.
    You realize so much its almost tough to argue with you (not that I
    actually will need to…HaHa). You definitely put a new spin on a topic
    which has been written about for decades. Great stuff, just great!

  3. I love your blog.. very nice colors & theme. Did you design this
    website yourself or did you hire someone to do it for
    you? Plz respond as I’m looking to design my own blog and would like to know where u got this from. thanks a lot

    • hi..thanks for ur compliments..i made this site by my own.i am a developer and i designed this by my own.for this kind of theme you can find it in wordpress themes ans you can apply it.

  4. Hmm it looks like your site ate my first comment (it
    was super long) so I guess I’ll just sum it up what I had written and say, I’m thoroughly enjoying your blog.
    I too am an aspiring blog writer but I’m still new to the whole thing. Do you have any tips and hints for novice blog writers? I’d
    really appreciate it.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s