How To Create a Spelling Check Website through javascript

Step 1:- Create a html page

<div class="container">
                     <h1>Spell Check Search</h1>
                     <br><br>
                     
                     
                        <textarea id="textarea" class="textarea" maxlength="150" placeholder="Type something here..." required></textarea>

                        <div class="counter-container">
                           <p> Total character: <span id="total-counter"> 0 </span></p>&nbsp;&nbsp;
                           <p> Remaining character: <span id="remaining-counter"> 150</span></p>
                        </div>
                        <div class="butonwa">
                           <button id="Button">Correct Text </button>
                           <!-- <button id="copy"> Copy Text</button> -->
                        </div>
                     

                     <!-- <ul id="synonymsList"></ul> -->
                  </div>

Step 2:- Add on html page

<script src="script.js"></script>

Step 3:- Create a script.js

const charVal = document.getElementById("textarea");
let totalcount = document.getElementById("total-counter");
let remainingcount = document.getElementById("remaining-counter");
const button= document.querySelector("#Button");
const copy=document.querySelector("#copy")

let userChar = 0;

const updateCounter = () => {
    totalcount.innerText = charVal.value.length;
    remainingcount.innerText = 150 - charVal.value.length;
};


                var textarea = document.getElementById("textarea");
        
                textarea.addEventListener("input", function() {
                  this.style.height = "60px";
                  this.style.height = (this.scrollHeight + 2) + "px";
                });
                

const copyText = async () => {
    charVal.select();
    charVal.setSelectionRange(0, 9999);
    navigator.clipboard.writeText(charVal.value);
}
const correctText = async ()=>{
    try {
        // send text to LanguageTool API for correction
        const response = await fetch("https://api.languagetool.org/v2/check", {
            method: "POST",
            headers: {
                "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
            },
            body: new URLSearchParams({
                text: charVal.value,
                language: "en-US",
                enabledOnly: "false"
            })
        });

        const data = await response.json();

        const correctedText = data.matches.reduce((text, match) => {
            const startIndex = match.offset;
            const endIndex = match.offset + match.length;
            const replacement = match.replacements[0].value;
            return text.slice(0, startIndex) + replacement + text.slice(endIndex);
        }, charVal.value);


        charVal.value = correctedText;
    } catch (error) {
        console.error(error);
    }
};



charVal.addEventListener("keyup", updateCounter);

copy.addEventListener("click", async () => {
    await copyText();
});

button.addEventListener("click", async () => {
    await correctText();
});

Search:-

Output:-

Add CSS what you want….

I hope it will help you … Happy Coding!!!!

Related Posts

Navigating Pipeline Risks with Expert DevSecOps Consulting Services

Software delivery moves faster today than at any point in technological history. High-performing engineering organizations push code changes to production multiple times a day using automated deployment…

Read More

DevOps Support Services: Key Practices for Stable Production Environments

Introduction Running modern software infrastructure is an ongoing responsibility. A development team may successfully launch an application, but keeping that application reliable in production requires continuous attention….

Read More

DevOps Learning Paths for Kubernetes, Cloud, Security, SRE, and MLOps

Introduction DevOps has become an important part of modern software engineering because development teams are expected to release software quickly without losing control over quality, security, or…

Read More

Best Practices for Multi-Cloud Tool Integration: A Practical DataOps Guide

Introduction Modern organizations rarely rely on a single cloud provider. As enterprise data architectures evolve, teams frequently operate across combinations of Amazon Web Services (AWS), Microsoft Azure,…

Read More

Enterprise DataOps Adoption: How TheDataOps.org Simplifies Transformation

Introduction Modern enterprises run on data. Every strategic business decision, real-time dashboard, predictive financial forecast, and customer-facing machine learning model relies on continuous data streams. However, as…

Read More

Expert Tips for Evaluating Best Dental Hospitals Overseas

Introduction Navigating complex dental care—whether for a single missing tooth, extensive cosmetic restoration, or full-mouth reconstruction—represents a significant personal, clinical, and financial decision. In recent years, global…

Read More
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x