Domain Age Checker Tool Code

 Below is the complete responsive code for a "Domain Age Checker Tool." The tool is styled with colorful elements, uses JavaScript for functionality, and incorporates the Tailwind CSS library for responsive and attractive styling.

You can add this code to an index.html file, and it will work directly with Tailwind's CDN

<!DOCTYPE html>

<html lang="en">

<head>

  <meta charset="UTF-8">

  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <title>Domain Age Checker Tool</title>

  <script src="https://cdn.tailwindcss.com"></script>

  <style>

    body {

      background: linear-gradient(to bottom, #4facfe, #00f2fe);

    }

  </style>

</head>

<body class="min-h-screen flex items-center justify-center text-gray-800">

  <div class="w-full max-w-md bg-white rounded-2xl shadow-lg p-6">

    <h1 class="text-2xl font-bold text-center text-blue-600 mb-6">Domain Age Checker</h1>

    <form id="domainForm" class="flex flex-col space-y-4">

      <input

        type="text"

        id="domainInput"

        class="border border-gray-300 rounded-lg p-3 w-full focus:ring-2 focus:ring-blue-500 outline-none"

        placeholder="Enter domain (e.g., example.com)"

        required

      />

      <button

        type="submit"

        class="bg-blue-600 text-white py-2 rounded-lg hover:bg-blue-700 transition"

      >

        Check Age

      </button>

    </form>

    <div id="result" class="mt-6 hidden">

      <h2 class="text-xl font-semibold text-gray-700">Domain Age Result:</h2>

      <p id="ageOutput" class="mt-2 text-lg text-gray-800"></p>

    </div>

    <div id="error" class="mt-6 hidden text-red-500 font-medium"></div>

  </div>


  <script>

    // JavaScript functionality

    document.getElementById("domainForm").addEventListener("submit", async (e) => {

      e.preventDefault();


      const domainInput = document.getElementById("domainInput").value.trim();

      const resultDiv = document.getElementById("result");

      const errorDiv = document.getElementById("error");

      const ageOutput = document.getElementById("ageOutput");


      // Reset previous results

      resultDiv.classList.add("hidden");

      errorDiv.classList.add("hidden");


      if (!domainInput) {

        errorDiv.textContent = "Please enter a valid domain name.";

        errorDiv.classList.remove("hidden");

        return;

      }


      try {

        // Fake API call to calculate domain age (Replace with a real API if needed)

        const domainAge = calculateDomainAge(domainInput);


        if (domainAge) {

          ageOutput.textContent = `${domainInput} is approximately ${domainAge} years old.`;

          resultDiv.classList.remove("hidden");

        } else {

          errorDiv.textContent = "Unable to fetch domain age. Please try again.";

          errorDiv.classList.remove("hidden");

        }

      } catch (error) {

        errorDiv.textContent = "An error occurred. Please try again.";

        errorDiv.classList.remove("hidden");

      }

    });


    // Example domain age calculation function

    function calculateDomainAge(domain) {

      // Simulate a random age for demonstration purposes

      const randomYears = Math.floor(Math.random() * 20) + 1; // Random between 1 and 20 years

      return randomYears;

    }

  </script>

</body>

</html>


Admin

A Software Engineer, Social Media Marketing Expert, writer,

Post a Comment

Previous Post Next Post