• We just launched and are currently in beta. Join us as we build and grow the community.

JavaScript Validation API with DOM

Sakura997

Ridiculousness Analyst
S Rep
0
0
0
Rep
0
S Vouches
0
0
0
Vouches
0
Posts
158
Likes
178
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 300 XP
  1. <!DOCTYPE html>
  2. <html

    >

  3. <body

    >

  4. <p

    >

    Enter a number and click Here Button:</

    p

    >

  5. <input

    id

    =

    "1"

    type

    =

    "number"

    min=

    "5"

    max=

    "10"

    required>
  6. <button

    onclick

    =

    "myFunction()"

    >

    OK</

    button

    >

  7. <p

    >

    If the number is less than 5 or greater than 10, an error message will be displayed.</

    p

    >

  8. <p

    id

    =

    "test"

    ></

    p

    >

  9. <script

    >
  10. function myFunction() {
  11. var inpObj = document.getElementById("1");
  12. if (!inpObj.checkValidity()) {
  13. document.getElementById("test").innerHTML = inpObj.validationMessage;
  14. } else {
  15. document.getElementById("test").innerHTML = "OK";
  16. }
  17. }
  18. </

    script

    >

  19. </

    body

    >

  20. </

    html

    >

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.

FOR YOUR OWN SAFETY, PLEASE:

1. Re-scan downloaded files using your personal virus checker before using it.

2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.


Download
You must upgrade your account or reply in the thread to view hidden text.
 

440,010

316,559

316,568

Top