From e982a047fd9e72c9edaf6c7408a8b71243b40248 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francesco=20Munaf=C3=B2?= Date: Fri, 1 Jul 2016 15:58:37 +0200 Subject: [PATCH 1/3] Automatically transform password fields to text fields when a placeholder is used --- src/simple.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/simple.js b/src/simple.js index 218d874..68399b4 100644 --- a/src/simple.js +++ b/src/simple.js @@ -4,6 +4,8 @@ // Author: James Brumond (http://www.jbrumond.me) // +// Patched by Francesco Munafò to automatically transform password fields to text fields when a placeholder is used + (function(window, document, undefined) { // Don't run the polyfill if it isn't needed @@ -131,14 +133,26 @@ function checkPlaceholder() { if (elem.value) { + + /* FRANCESCOMM START */ + if(elem.wasPassword === true) {elem.type = 'password';} + /* FRANCESCOMM END */ + hidePlaceholder(); } else { + /* FRANCESCOMM START */ + if(elem.type === 'password') {elem.wasPassword=true; elem.type = 'text';} + /* FRANCESCOMM END */ + showPlaceholder(); } } function showPlaceholder() { if (! elem.__placeholder && ! elem.value) { + /* FRANCESCOMM START */ + if(elem.type === 'password') {elem.wasPassword=true; elem.type = 'text';} + /* FRANCESCOMM END */ doShowPlaceholder(); } } From 961d5587ce6f8d7aed7809100e50b7c5984f4748 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francesco=20Munaf=C3=B2?= Date: Fri, 1 Jul 2016 16:02:49 +0200 Subject: [PATCH 2/3] Remove fake input placeholders from inputs on submit --- src/siple_clean_submit.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/siple_clean_submit.js diff --git a/src/siple_clean_submit.js b/src/siple_clean_submit.js new file mode 100644 index 0000000..b9b15ae --- /dev/null +++ b/src/siple_clean_submit.js @@ -0,0 +1,27 @@ + + // This is a demo script to remove fake input placeholders (value="") from inputs on submit + // Or you can do it sever side + // francescomm + + $(document).on("submit",function(e) { + + + // remove placeholders from all fields before submitting + + $("input,textarea").each(function() { + var value=$(this).val(); + if($(this).val()!=="" && $(this).val()===$(this).attr("placeholder")) $(this).val(""); + }); + + + // in case submit fails, restore placeholders, after 1 second + + setTimeout(function() { + $("input,textarea").each(function() { + if($(this).val()==="" && $(this).attr("placeholder")!=="") $(this).val($(this).attr("placeholder")); + }); + },1000); + + //e.preventDefault(); // don't stop, (uncomment for testing) let the submitting go on + + }) From 3cc95c3f8f930996dc0c6f62766102baba754c4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francesco=20Munaf=C3=B2?= Date: Fri, 1 Jul 2016 16:04:23 +0200 Subject: [PATCH 3/3] Remove fake value placeholders from inputs on submit --- src/{siple_clean_submit.js => simple_clean_submit.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/{siple_clean_submit.js => simple_clean_submit.js} (100%) diff --git a/src/siple_clean_submit.js b/src/simple_clean_submit.js similarity index 100% rename from src/siple_clean_submit.js rename to src/simple_clean_submit.js