Jquery Prevent autofill form fields by browsers


/ Published in: jQuery
Save to your folder(s)



Copy this code and paste it in your HTML
  1. (function ($) {
  2.  
  3. var sTime = new Date().getTime();
  4. $(function () {
  5.  
  6. return $('form').each(function (i, frm) {
  7. var inputs = $(frm + ':input');
  8. $.each(inputs, function () {
  9. if ($(this).attr('type') == 'text') $(this).attr('name', $(this).attr('name') + "_" + sTime);
  10. });
  11.  
  12. $(frm).bind('submit', function () {
  13. var inputs = $(frm + ':input');
  14. $.each(inputs, function () {
  15. if ($(this).attr('type') == 'text') $(this).attr('name', $(this).attr('name').replace('_' + sTime, ''));
  16. });
  17. });
  18. });
  19. });
  20.  
  21. })(jQuery);

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.