Tuesday, 8 July 2014

Validate and replace char using jqery

if (str.indexOf('\'') >= 0 && str.indexOf('"') >= 0) {
   //do something
}

    $('#txt_pname').keyup(function () {
                var str = $('#txt_pname').val();
                if (str.indexOf('"') >= 0) {
                    //do something
                    $('#txt_pname').val(str.replace('"', ''));
                    alert('Double quote (") not allow.');
                }
            });

No comments:

Post a Comment