Javascript examples for jQuery:Form Input
auto fill 'http://' in input
<html> <head> <script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.js"></script> <script> $(document).ready(function() { $('#urlForm').submit(function() { var url = $('#address'); if(url.val().match(/^http:\/\//) == null) { url.val("http://" + url.val()); }// w w w.j a va 2s . c o m }); }); </script> </head> <body> <form id="urlForm"> <input id="address" type="text"> <button type="submit">Submit</button> </form> </body> </html>