Powiedzcie mi proszę czy to ma sens:
Celem skryptu jest aby w polu input text można było wpisywać hasło, tak jak w polu input[password], chodzi o to, że text nie jest nigdy zapamiętywany przez przeglądarki, a chcę osiągnąć taki efekt aby nie było widać co się wpisuje w pole text, ale można było przesłać jego zawartość do walidacji.
$(function() { $('#tb1').on("change paste keydown keyup", function(e) { if (e.which == 8) { var test = $('#txt').val(); var newstring = test.substring(0, test.length - 1) $('#txt').val(newstring); } var string = $('#txtCustName').val(); var txtClone = $(this).val(); $('#txtCustName').val(txtClone); // $("#txt").val(text_stord); string = $('#txtCustName').val(); var i = -1, length = $('#txt').val().length; for (i; i < length; i++) { string = string.replace(/./g, '*'); $("#tb1").val(string); } var j = -1, length2 = $('#txt').val().length; var test = $('#txt').val(); for (j; j < length2 + 1; j++) { test = test.replace(/\*/g, ""); $('#txt').val(test); } $("#txt").val(($("#txt").val()) + ($("#txtCustName").val().slice(-1))); if (($('#txt').val().length) > ($('#tb1').val().length)) { test = test.replace(/\*/g, ""); $('#txt').val(test); } }); });
działanie skryptu można zobaczyć na
http://jsfiddle.net/e9KFT/205/