jquery - .replace() is only temporary, javascript -
im creating forum page, , forming comments section now. since when press homecoming type \n in text area, result of text this: ends 'a a'. submitting text database hence have perform function, before submission. have used onsubmit on form , directed next function:
function cleartext() { $('#commentbox').val().replace(/\n/g,'<br>'); console.log($('#commentbox').val());
when manually on console see converts newline tags br tags. when run code, $('#commentbox').val() doesnt alter @ all. there other way of calling function before submission? or there way of making .replace() alter permanent? give thanks in advance!
now getting value, should set value,
function cleartext() { $('#commentbox').val($('#commentbox').val().replace(/\n/g, '<br>')); console.log($('#commentbox').val()); }
jquery forms
No comments:
Post a Comment