get all checkbox value in jquery

var checked = []
$(“input[name=’inboxCheckBox[]’]:checked”).each(function ()
{
checked.push($(this).val());
});

***************************************************************

$.each( checked, function( key, value ) {
alert( key + “: ” + value );
});

 

 

Advertisements

Validation Rules Method and Syntex

Syntex :

$(function(){
$(“#login_form”).validateset({
rules: {
fieldname: { method },
},
messages: {
fieldname: { method },
}
});
});

Required JS File :

<script src=”js/jquery.js” type=”text/javascript”></script>
<script src=”js/jquery.validate.min.js” type=”text/javascript”></script>

Predefine Method :

  • Required: The typical and probably most used validation out there.
  • Minlength & Maxlength: Staple Length validation rules
  • Rangelength: Similar to Min/Maxlength; allows for selected item counts as well.
  • Min & Max & Range: Same as the “length” rules above only for numeric values.
  • Email: A very robust email validation rule
  • Url: Ensures the input is a well formatted url.
  • Date: Verifies the input can be parsed into a date.
  • Number: Ensures that the input is numeric.
  • Digits: Ensures only 0-9 characters (no commas, decimal points, etc.)
  • Credit Cards: Another complex and common validation rule made easy.
  • Accept: A file extension validation rule.
  • EqualTo: Ensures that the values of 2 elements are the same.

Allowed only Alphanumeric character

<script src=”js/jquery.js” type=”text/javascript”></script>
<script src=”js/jquery.validate.min.js” type=”text/javascript”></script>
<script type=”text/javascript”>
$(document).ready(function(){
$(“#mobilejj”).bind(‘keyup’, function(){
var TCode = document.test_form.mobilejj.value;
for(var i=0; i<TCode.length; i++)
{
var char1 = TCode.charAt(i);
var cc = char1.charCodeAt(0);
if((cc>47 && cc<58) || (cc>64 && cc<91) || (cc>96 && cc<123))
{
}
else
{
alert(‘Special character are not allowed\n\nPlease enter only alphanumeric’);
$(“#mobilejj”).val(”);
return false;
}
}
});
});
</script>

<form name=”test_form” id=”test_form” action=”” enctype=”multipart/form-data”>
<input type=”text” name=”mobilejj” id=”mobilejj” value=”” >
<input type=”text” name=”phonejj” id=”phonejj” value=””>
<input type=”submit” name=”test_send” id=”test_send” value=”Submit”>
</form>

Open Image in Color Box

<script src=”js/jquery.colorbox.js” type=”text/javascript”></script>
<script type=”text/javascript”>
$(document).ready(function(){
//Examples of how to assign the Colorbox event to elements
$(“.group4”).colorbox({rel:’group4′, slideshow:true});
//Example of preserving a JavaScript event for inline calls.
$(“#click”).click(function(){
$(‘#click’).css({“background-color”:”#f00″, “color”:”#fff”, “cursor”:”inherit”}).text(“Open this window again and this message will still be here.”);
return false;
});
});
</script>

<a class=”group4″  href=”ads_image/<?php echo $imgre[‘img_name’]; ?>” title=”Nice Image”><img src=”ads_image/<?php echo $imgre[‘img_name’]; ?>” width=”100″ height=”70″ /></a>

Jquery Validation

<script src=”js/jquery.validate.min.js” type=”text/javascript”></script>

<script type=”text/javascript”>
$(function(){
$(“#register_form”).validateset({
rules: {
fname: { required: true, maxlength: 64 },
lname: { required: true, maxlength: 64 },
r_users: { required: true, maxlength: 64, remote: “getemailval.php” },
r_emails: { required: true, email: true, maxlength: 32, remote: “getemailval.php” },
r_pass: { required: true, maxlength: 64 },
},
messages: {
fname: { required: “First Name is Required” },
lname: { required: “Last Name is Required” },
r_users: { required: “User Name is Required”, remote: “User Name Allready Exist” },
r_emails:{ required: “Email Id  is Required”, remote: “Email Id Allready Exist” },
r_pass: { required: “Password  is Required” },
}
});
});
</script>

<form name=”register_form” id=”register_form” method=”post” action=”signup_action.php” enctype=”multipart/form-data” target=”_parent” onSubmit=”return validateset();”>
<ul>
<li>First Name <span>*</span> :</li>
<li><input type=”text” value=”” id=”fname” name=”fname”></li>
</ul>
<ul>
<li>Last Name <span>*</span> :</li>
<li><input type=”text” value=”” id=”lname” name=”lname”></li>
</ul>
<ul>
<li>User Name <span>*</span> :</li>
<li><input type=”text” value=”” id=”r_users” name=”r_users” ></li>
</ul>
<ul>
<li>Email Id <span>*</span> :</li>
<li><input type=”text” value=”” id=”r_emails” name=”r_emails” ></li>
</ul>
<ul>
<li>Password <span>*</span> :</li>
<li><input type=”password” value=”” id=”r_pass” name=”r_pass” ></li>
</ul>
<ul>
<li><input type=”submit” name=”send” id=”send” value=”Create Account”></li>
</ul>
</form>