Javascript examples for DOM HTML Element:Input Submit
Prepend text to input value on form submit
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <script> function AppendText(name) {/*from w ww . ja v a 2 s . c o m*/ var val = document.getElementsByName(name)[0]; val.value = "Number:" + val.value; console.log(val.value); } </script> <form onsubmit="AppendText('num')"> Enter invoice number: <input type="text" name="num"> <input type="submit"> </form> </body> </html>