Add an external input value to form on submit
forms, javascript, jquery
Solution
Create a hidden field in the form and copy the password field value to that field on submit. Like this.
<form action="" accept-charset="utf-8" method="post">
<textarea name="content"></textarea>
<input type="hidden" name="password" id="ps">
</form>
<input type="password" name="password" id="ps1">
And in on submit function.
$('form').submit(function(){
$('input#ps').val($('input#ps1').val());
return true;
});
Problem
I have a typical form: ``` <form action="" accept-charset="utf-8" method="post"> <textarea name="content"></textarea> </form> ``` and an not-inside-a-form element: ``` <input type="password" name="password"> ``` How do I add the value of password into the form when I submit the form? ``` $('form').submit(function(){ //hmmm }); ```