diff --git a/JavaScript/Advance/DOM/5. DOM Form/css/style.css b/JavaScript/Advance/DOM/5. DOM Form/css/style.css new file mode 100644 index 0000000..bd7da16 --- /dev/null +++ b/JavaScript/Advance/DOM/5. DOM Form/css/style.css @@ -0,0 +1,3 @@ +h2 { + font-family: monospace; +} \ No newline at end of file diff --git a/JavaScript/Advance/DOM/5. DOM Form/images/js-logo.png b/JavaScript/Advance/DOM/5. DOM Form/images/js-logo.png new file mode 100644 index 0000000..4637ac9 Binary files /dev/null and b/JavaScript/Advance/DOM/5. DOM Form/images/js-logo.png differ diff --git a/JavaScript/Advance/DOM/5. DOM Form/index.html b/JavaScript/Advance/DOM/5. DOM Form/index.html new file mode 100644 index 0000000..d92cc72 --- /dev/null +++ b/JavaScript/Advance/DOM/5. DOM Form/index.html @@ -0,0 +1,30 @@ + + + +
+ + + +Please input a number between 1 and 10:
+ + + + + + + + + + \ No newline at end of file diff --git a/JavaScript/Advance/DOM/5. DOM Form/script.js b/JavaScript/Advance/DOM/5. DOM Form/script.js new file mode 100644 index 0000000..6e4b6db --- /dev/null +++ b/JavaScript/Advance/DOM/5. DOM Form/script.js @@ -0,0 +1,25 @@ +// Example One +function validateForm() { + let x = document.forms["myForm"]["fname"].value; + if (x == "") { + alert("Name must be filled out"); + return false; + } +} + + +//Example Two +let textOne = document.getElementById('textOne'); + +function FunctionOne() { + // Get the value of the input field with id="numb" + let x = document.getElementById("numb").value; + // If x is Not a Number or less than one or greater than 10 + let text; + if (isNaN(x) || x < 1 || x > 10) { + text = "Input not valid"; + } else { + text = "Input OK"; + } + textOne.innerHTML = text; +} \ No newline at end of file