<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Khodzhaev Khozhiakbar</title>
    <description>The latest articles on DEV Community by Khodzhaev Khozhiakbar (@khodzhaev).</description>
    <link>https://dev.to/khodzhaev</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1015124%2Fb526d60e-a681-4ab1-ad0c-7dfb2b8df025.jpeg</url>
      <title>DEV Community: Khodzhaev Khozhiakbar</title>
      <link>https://dev.to/khodzhaev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/khodzhaev"/>
    <language>en</language>
    <item>
      <title>JavaScript Password Strength Validation Example (PURE JS)</title>
      <dc:creator>Khodzhaev Khozhiakbar</dc:creator>
      <pubDate>Thu, 26 Jan 2023 14:57:01 +0000</pubDate>
      <link>https://dev.to/khodzhaev/javascript-password-strength-validation-example-pure-js-2c4i</link>
      <guid>https://dev.to/khodzhaev/javascript-password-strength-validation-example-pure-js-2c4i</guid>
      <description>&lt;p&gt;I have long been interested in how to make validators passwords, and I searched the Internet a lot of options, but could not find one which was short and clear + to be written in pure JS, I now want to share with my version of the code, may be for beginners will help.&lt;/p&gt;

&lt;p&gt;In the past few years, I have been interested in writing my own password validator. At first, I thought it would be easy, but after some research and experimentation, I found out that there are many ways to validate passwords and each has its own advantages and disadvantages.&lt;/p&gt;

&lt;p&gt;I did not want to use any third-party libraries or services because it would make the code harder to understand for beginners. Therefore, this article describes an implementation of a simple password validator written entirely in JavaScript without any external dependencies.&lt;/p&gt;

&lt;p&gt;CSS&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        h4 {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            margin-bottom: 5px;
        }
        #block {
            width: 300px;
        }
        input {
            display: block;
            padding: 5px 10px;
            margin-bottom: 5px;
            width: 100%;
        }
        .status {
            width: 100%;
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            grid-gap: 2px;
        }
        .status div {
            padding: 5px;
        }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;HTML&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div id="block"&amp;gt;
            &amp;lt;h4&amp;gt;Parolni mukammaligi&amp;lt;/h4&amp;gt;
            &amp;lt;input type="text" placeholder="Enter password"&amp;gt;
            &amp;lt;div class="status"&amp;gt;
                &amp;lt;div class="status_bar"&amp;gt;&amp;lt;/div&amp;gt;
                &amp;lt;div class="status_bar"&amp;gt;&amp;lt;/div&amp;gt;
                &amp;lt;div class="status_bar"&amp;gt;&amp;lt;/div&amp;gt;
                &amp;lt;div class="status_bar"&amp;gt;&amp;lt;/div&amp;gt;
            &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;JS&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; let input = document.querySelector('input')
        let bars = document.querySelectorAll('.status_bar')

        function check_lower_case(x) {
            for (let i of x) {
                if ("abcdefghijklmnopqrstuvwxyz".includes(i)) {
                    return 1
                }
            }
            return 0
        }

        function check_upper_case(x) {
            for (let i of x) {
                if ("ABCDEFGHIJKLMNOPQRSTUVWXYZ".includes(i)) {
                    return 1
                }
            }
            return 0
        }

        function check_digits(x) {
            for (let i of x) {
                if ("0123456789".includes(i)) {
                    return 1
                }
            }
            return 0
        }

        function check_spec_char(x) {
            for (let i of x) {
                if ("!@#$%^&amp;amp;*()-+".includes(i)) {
                    return 1
                }
            }
            return 0
        }


        input.addEventListener('input', ()=&amp;gt; {

            let point = 0

            point += check_lower_case(input.value)
            point += check_upper_case(input.value)
            point += check_digits(input.value)
            point += check_spec_char(input.value)

            if (point == 4) {
                bars[0].style.backgroundColor = 'green'
                bars[1].style.backgroundColor = 'green'
                bars[2].style.backgroundColor = 'green'
                bars[3].style.backgroundColor = 'green'
            } else if (point == 3) {
                bars[0].style.backgroundColor = 'yellow'
                bars[1].style.backgroundColor = 'yellow'
                bars[2].style.backgroundColor = 'yellow'
                bars[3].style.backgroundColor = 'transparent'
            } else if (point == 2) {
                bars[0].style.backgroundColor = 'orange'
                bars[1].style.backgroundColor = 'orange'
                bars[2].style.backgroundColor = 'transparent'
                bars[3].style.backgroundColor = 'transparent'
            } else if (point == 1) {
                bars[0].style.backgroundColor = 'red'
                bars[1].style.backgroundColor = 'transparent'
                bars[2].style.backgroundColor = 'transparent'
                bars[3].style.backgroundColor = 'transparent'
            } else {
                bars[0].style.backgroundColor = 'transparent'
                bars[1].style.backgroundColor = 'transparent'
                bars[2].style.backgroundColor = 'transparent'
                bars[3].style.backgroundColor = 'transparent'
            }
        })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>career</category>
      <category>productivity</category>
      <category>discuss</category>
    </item>
  </channel>
</rss>
