user244394 user244394 - 1 year ago 85
Javascript Question

removing strings or characters from variables

How do i go about removing "#" and "@" from the variable using jquery ?

example var inputval ="#111-111-1111" or ""

var inputval =$(this).siblings("input[type=text]").val();
alert("inputval " +inputval);


$('#some-text').val($('#some-text').val()+' ' + inputval);


Answer Source

There's no need to use jQuery to accomplish this task, straight JavaScript will do:

inputval = inputval.replace(/[#@]/g, "");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download