Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type="text/javascript" >
- function FirstNameIsValid() {
- st = document.getElementById("fname").value;
- var ok=true;
- if (Number(st))
- {
- alert("You must enter a valid First Name(not numbers only letters!)");
- document.getElementById("fname").focus();
- ok=false;
- }
- if (st == "") {
- alert("You must enter a First Name");
- document.getElementById("fname").focus();
- ok=false;
- }
- return ok;
- }
- function LastNameIsValid() {
- st = document.getElementById("lname").value;
- var ok=true;
- if (Number(st))
- {
- alert("You must enter a valid Last Name(not numbers only letters!)");
- document.getElementById("fname").focus();
- ok=false;
- }
- if (st == "") {
- alert("You must enter a last name");
- document.getElementById("lname").focus();
- ok=false;
- }
- return ok;
- }
- function AgeIsValid() {
- st = document.getElementById("yearBorn").value;
- var ok=true;
- if (st == "") {
- alert("You must enter an age(year)");
- document.getElementById("yearBorn").focus();
- ok=false;
- }
- if (isNaN(st)) {
- alert("Error, you must enter an apropriate age (year)");
- document.getElementById("yearBorn").focus();
- ok=false;
- }
- else {
- if (Number(st) < 1930 || Number(st) > 2012) {
- alert("Enter an valid year");
- document.getElementById("yearBorn").focus();
- ok=false;
- }
- }
- return ok;
- }
- function PhoneIsValid() {
- var st = document.getElementById("Select1").options.value + "-" + document.getElementById("tel").value;
- var st2 = document.getElementById("tel").value;
- var ok=true;
- if (isNaN(st2)) {
- alert("Error: you must enter numbers only in phone!!");
- document.getElementById("tel").focus();
- ok=false;
- }
- if (st2.length != 7) {
- alert("You must enter a 7 digit number phone number");
- document.getElementById("tel").focus();
- ok=false;
- }
- if (st2 == "") {
- alert("You must enter a phone number");
- document.getElementById("tel").focus();
- ok=true;
- }
- return ok;
- }
- function EmailIsValid() {
- var stEmail = document.getElementById("email").value;
- var ok=true;
- if (stEmail == "") {
- alert("You must enter an email");
- document.getElementById("email").focus();
- ok=true;
- }
- else {
- if (stEmail.indexOf("@") < 0) {
- alert("Email must have @");
- document.getElementById("email").focus();
- ok=false;
- }
- if (stEmail.indexOf(".") < 0) {
- alert("Email must have (.)");
- document.getElementById("email").focus();
- }
- }
- return ok;
- }
- function isvalid()
- {
- if ( FirstNameIsValid() && LastNameIsValid() && PhoneIsValid() && EmailIsValid() && AgeIsValid();
- return true;
- return false;
- }
- function submitForm()
- {
- if (isvalid())
- form1.submit();
- }
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement