Steve Aged
Steve Aged

Reputation: 143

Changing form serialize data

after a JS form serialize i have this:

.....&xx=xxx&otherError=&input=SMS&message=sdfgs&......

How can i change message val before ajax call putting a textarea val?

Thanks in advance,

Steve

Upvotes: 0

Views: 604

Answers (1)

Pranav C Balan
Pranav C Balan

Reputation: 115212

Using String#replace method update the string.

var str = '.....&xx=xxx&otherError=&input=SMS&message=sdfgs&......';

str = str.replace(/&message=[^&]+/, '&message=newvalue');

console.log(str);


Or update the input field value before serializing.

$('[name="message"]').val('newvalue');

Upvotes: 1

Related Questions