Important Notice:

Form Validation in JS

Form Validation in JS

20 views 1 min read

 

Form Validation :-

English: Form Validation is the process of checking whether the user has filled the form correctly before submitting it. It helps in getting clean and correct data.

Hindi: फॉर्म वैलिडेशन वह प्रक्रिया है जिसमें हम चेक करते हैं कि यूजर ने फॉर्म सही तरीके से भरा है या नहीं, सबमिट करने से पहले। इससे सही और साफ डेटा मिलता है।

2. Types of Form Validation

  1. HTML5 Validation (Built-in - सबसे आसान)
  2. JavaScript Validation (Custom Logic)

1-HTML5 Built-in Validation

HTML में ही कुछ attributes लगाकर validation कर सकते हैं:

<form id="myForm">
    <input type="text" name="name" required placeholder="Full Name">
    <input type="email" name="email" required placeholder="Email">
    <input type="number" name="age" min="18" max="100" placeholder="Age">
    <button type="submit">Submit</button>
</form>

 
 

Related Notes