Posts

Showing posts with the label jquery replace

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);     }