-1

In this question there are the following answers of this question but i give the best answer of this question.

  function myFunction() {
      var data = document.getElementById("myInput");
      if (data.type === "password") {
        data.type = "text";
      } else {
        data.type = "password";
      }
    }
<div class="form-group col-md-6">
<label class="control-label">Password</label>
<input type="Password" name="password password1" id="myInput" class="form-control eye" value="{{old('password')}}">
<i class="fa fa-eye" aria-hidden="true" onclick="myFunction()"> Show Hide</i>                                                             {!! $errors->first('password', '<p class="text-warning errorBag">:message</p>') !!}
</div>

Share my answer please

Mohammad
  • 1,549
  • 1
  • 15
  • 27
Siraj Ahmed
  • 128
  • 2
  • 6

5 Answers5

1

Here is a shorter approach:

    var input = document.getElementById("myInput");
    function myFunction()
    { input.type = input.type === "password" ? "text" : "password" }

Trevor Reid
  • 3,310
  • 4
  • 27
  • 46
Bhavya Singh
  • 311
  • 2
  • 14
0
function myFunction() {
  var data = document.getElementById("myInput");
  var curType = data[0].getAttribute("type");
  if (curType === "password") {
    data.[0].setAttribute("type","text");

  } else {
    data.[0].setAttribute("type","password");

  }
}
0

I am not finding any mistake or wrong in your code, You can use following link for your answer: https://www.w3schools.com/howto/howto_js_toggle_password.asp

Sunny Rajdeep
  • 151
  • 1
  • 3
  • A link to a solution is welcome, but please ensure your answer is useful without it: [add context around the link](//meta.stackexchange.com/a/8259) so your fellow users will have some idea what it is and why it’s there, then quote the most relevant part of the page you're linking to in case the target page is unavailable. [Answers that are little more than a link may be deleted.](//$SITEURL$/help/deleted-answers) – SecretAgentMan Jan 06 '20 at 18:01
0

Try This:

<script type="text/javascript">  
            $(document).ready(function () {  
                $('#show_password').hover(function show() {  
                    //Change the attribute to text  
                    $('#txtPassword').attr('type', 'text');  
                    $('.icon').removeClass('fa fa-eye-slash').addClass('fa fa-eye');  
                },  
                function () {  
                    //Change the attribute back to password  
                    $('#txtPassword').attr('type', 'password');  
                    $('.icon').removeClass('fa fa-eye').addClass('fa fa-eye-slash');  
                });  
                //CheckBox Show Password  
                $('#ShowPassword').click(function () {  
                    $('#Password').attr('type', $(this).is(':checked') ? 'text' : 'password');  
                });  
            });  
        </script>  
Arjun Ghimire
  • 233
  • 1
  • 6
0

you can try this

html code

<div class="form-group col-md-6">
<label class="control-label">Password</label>
<input type="Password" name="password password1" id="myInput" class="form-control eye" value="{{old('password')}}">
<button class="fa fa-eye" aria-hidden="true" onclick="myFunction()"> Show Hide</button>                                                     </div>

css code

 function myFunction() {
      var data = document.getElementById("myInput");
      if (data.type === "password") {
        data.type = "text";
      } else {
        data.type = "password";
      }
    }
Siraj Ahmed
  • 128
  • 2
  • 6