# ১৯-২ : regex ব্যবহার করে পাসওয়ার্ড ভ্যালিডেশন

এই মডিউলে আমরা রেজিস্ট্রেশন ফর্মের ভ্যালিডেশন করব।

এর জন্য auth.js ফাইলের handleRegistration( )  ফাঙ্গশন নিচের মত করে  লিখে ফেলি-

<mark style="color:green;">**Code:: 19.2.1**</mark> \ <mark style="color:red;">app.js</mark>

```javascript
...
...
...
    
  const handleRegistration = (event) => {
    event.preventDefault();
    const username = getValue("username");
    const first_name = getValue("first_name");
    const last_name = getValue("last_name");
    const email = getValue("email");
    const password = getValue("password");
    const confirm_password = getValue("confirm_password");
    const info = {
      username,
      first_name,
      last_name,
      email,
      password,
      confirm_password,
    };
  
    if (password === confirm_password) {
      document.getElementById("error").innerText = "";
      if (
        /^(?=.*[A-Za-z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!%*#?&]{8,}$/.test(
          password
        )
      ) {
        console.log(info);
  
        fetch("https://testing-8az5.onrender.com/patient/register/", {
          method: "POST",
          headers: { "content-type": "application/json" },
          body: JSON.stringify(info),
        })
          .then((res) => res.json())
          .then((data) => console.log(data));
      } else {
        document.getElementById("error").innerText =
          "pass must contain eight characters, at least one letter, one number and one special character:";
      }
    } else {
      document.getElementById("error").innerText =
        "password and confirm password do not match";
      alert("password and confirm password do not match");
    }
  };

...
...
...

```

এখন , password ও confirm\_password ফিল্ডে সেইম ইনপুট না দিলে ইরোর মেসেজ পাওয়া যাচ্ছে-

<figure><img src="https://3753355949-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZjZRCk5NYynvfinzJmZE%2Fuploads%2F7b0yoAkIanRDc9D2ijqo%2Fimage.png?alt=media&#x26;token=ccc661c4-779d-4d18-9e33-715eee8cfad8" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3753355949-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZjZRCk5NYynvfinzJmZE%2Fuploads%2FSBuUrHqaiELxoOef4qBQ%2Fimage.png?alt=media&#x26;token=33198879-0df0-46f8-9bf3-28165dc0469f" alt=""><figcaption></figcaption></figure>

.
