- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
HTM5 checkValidity() method
The HTML5 checkValidity() works in Google Chrome and Opera as well. This works as well:
<!DOCTYPE html> <html> <body> <style> .valid { color: #0B7866; } .invalid { color: #0B6877; } </style> <div id="result"></div> <script> function check(input) { var out = document.getElementById('result'); if (input.validity) { if (input.validity.valid === true) { out.innerHTML = "<span class='valid'>" + input.id + " valid</span>"; } else { out.innerHTML = "<span class='invalid'>" + input.id + " not valid</span>"; } } console.log(input.checkValidity()); }; </script> <form id="testform" onsubmit="return false;"> <label>Minimum: <input oninput="check(this)" id="min_input" type=number min=4 /> </label><br> </form> </body> </html>
Advertisements