Posts

Showing posts with the label JQUERY

sticky menu after scroll fixed to top using jquery

HTML     Please scroll                         This needs to be fixed when hits top of screen         CSS .fixed {     position: fixed;     top:0; left:0;     width: 100%; } .sticky-header {     width:700px;     height:50px;     background:orange;     postion:fixed; } JSS $(window).scroll(function(){     if ($(window).scrollTop() >= 330) {        $('.sticky-header').addClass('fixed');     }     else {        $('.sticky-header').removeClass('fixed');     } });

jQuery Datepicker close datepicker after selected date

HTML <div class = "container" > <div class = "hero-unit" > <input type = "text" class = "dp" placeholder = "click to show datepicker" id = "example1" > </div> </div> jQuery (alternativ way) $ ( document ). ready ( function () { $ ( '#example1' ). datepicker ({ format : "dd/mm/yyyy" }); $ ( '.dp' ). on ( 'change' , function (){ $ ( '.datepicker' ). hide (); }); }); this is all you have to do :) HERE IS A FIDDLE to see whats happening.

JQuery validate input fileds on keyup event

Image
<html><head>   <script type="text/javascript" src="//code.jquery.com/jquery-1.8.3.js"></script>       <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.10.0/jquery.validate.min.js"></script> <script type="text/javascript">//<![CDATA[ $(window).load(function(){ $(document).ready(function() {     $('#authForm').validate({         onkeyup: false,         rules: {             login: {                 // customRule: true,                 required: true,                 minlength: 6 // for demo   ...

jquery validate rules for only number

 $('#myform').validate({         rules: {             name: {                 required: true             },             mobileno: {                 required: true,                 number: true,                 minlength: 10,                 maxlength: 10             } } });

html select only one checkbox in a group

Image
$('input[type="checkbox"]').on('change', function() {    $(this).siblings('input[type="checkbox"]').not(this).prop('checked', false); }); First method <html><head>   <script type="text/javascript" src="//code.jquery.com/jquery-2.1.0.js"></script> <script type="text/javascript">//<![CDATA[ $(window).load(function(){ $('input[type="checkbox"]').on('change', function() {    $(this).siblings('input[type="checkbox"]').not(this).prop('checked', false); }); });//]]> </script> </head> <body>   <div>     <span>Group 1:</span>     <input class="group1" checked="" type="checkbox">     <input class="group1" type="checkbox">     <input class="group1" type="checkbox"> </div> <div>     <sp...

Getting checkbox values on submit

        <form action = "third.php" method = "get" > Red <input type = "checkbox" name = "color[]" id = "color" value = "red" > Green <input type = "checkbox" name = "color[]" id = "color" value = "green" > Blue <input type = "checkbox" name = "color[]" id = "color" value = "blue" > Cyan <input type = "checkbox" name = "color[]" id = "color" value = "cyan" > Magenta <input type = "checkbox" name = "color[]" id = "color" value = "Magenta" > Yellow <input type = "checkbox" name = "color[]" id = "color" value = "yellow" > Black <input type = "checkbox" name = "color[]" id = "color" value = "black" > ...