Benny Sutton is 4 hire - just click here

Test fill HTML form fields

Automatically fill HTML form fields

Do you ever think it would be very handy when working on forms to be able to fill in all the fields with one click?

Here's how. It works by looping over all textareas and inputs and setting their value to the text (you can change) below. You will need JQuery loaded for this to work.

See the working demo below.

Demo: Automatically fill HTML form fields

JavaScript

This is pretty much the standard JQuery you'll paste into your form page script block - or in a .js file if you prefer.

             
     $(document).ready(function () {
            $(".btn-test").click(function () {
                $("textarea:visible").val("Test multi line");
                $("input:visible").val("Test input");
            });
        });
       
    

Conclusion

a few lines of JQuery is all you need to test fill html form fields