user244394 user244394 - 7 months ago 12
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 "@some@email.com"

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

///$("#some-text").append('a'+inputval+'a');


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


Thanks

Answer

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

inputval = inputval.replace(/[#@]/g, "");
Comments