Posts

Showing posts with the label jquery

JQuery : Simple Regular expression for Email validation

Email validation is always required when we have a form or login / sign up pages. If we are using JQuery, the below regular expression will be simple and easy to use for validating an email address. Testemail = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/i; So we can write this in a function : function TestValidEmail(sEmail) { var Testemail  = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/i ; if ( Testemail   .test(sEmail)) { return true; } else { return false; } }

Jquery: replace character of select drop down values with other

below code snippet can be used to replace "-"  of select drop down values with ",". JQuery('#sel_test option:contains ("-")).each function(index,option)    {       var sval = JQuery(option).val().replace(/\-/g,",");       JQuery(option).val(sval);       JQuery(option).html(sval);     }

Jquery: how to validate time format HH:MM

There are many ways to validate HH:MM format. Below function also can be used to validate HH:MM format. function ValidateTime(value) {   var timepattern = /^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$/;   if (value.match(timepattern ))     {        return true;     }  return false; }

Progress bar for scrolling using JQuery

<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script> <script> $(document).ready(function () {     $(window).scroll(function () {         var top = $(this).scrollTop(),             sheight = $(document).height(),             scrll = (top / sheight);         var position = (scrll)*100;             $("#progress_bar").attr('value', position);      });  }); </script> <progress id="progress_bar" value="0" max="80" style="position:fixed; top:15px;" ></progress> <br /><br /><br /> text1<br /><br /> text2<br /><br /> text3<br /><br /> text4<br /><br /> text5<br /><br /> text1<br /><br /> text2<br /><br /> text3<br /><br /> text4<br /><br /> text5<br /><br /> text1<br /><br /> text2<br /><br