Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var firstName = document.getElementById("name1").value; //creates first name variable
- var age = document.getElementById("age").value; //creates age variable
- var secondName = document.getElementById("name2").value; //creates second name variable
- Submitted = "true"; //submits data...
- if (firstName.length > 15) { //unless if the name is longer than 15 characters
- alert("The name must have no more than 15 characters!") //for which you'll get an alert
- Submitted = "false"; //and your data won't be submitted
- }
- if (isNaN(age) || age < 10 || age > 120) { //or your age is below 10 or over 120
- alert("The age must be between numbers 10 and 120!") //for which you'll get an alert
- Submitted = "false"; //and your data won't be submitted
- }
- if (secondName.length > 15) //unless if the name is longer than 15 characters
- alert("The name must have no more than 15 characters!") //for which you'll get an alert
- Submitted = "false"; //and your data won't be submitted (again lol)
- }
- if (Submitted == "false") { //if it isn't submitted...
- return false; //it doesn't do anything
- }
- //the end...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement