JavaScript One Page Validation

-- 1 comment
Aello This is a Simple JS Validation example Only to understand how it works.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<!doctype html>
<html>
 <head>
  <title>This is a Test JavaScript Validation page</title>
  <script>
   function check() {
    var x = document.forms["test"]["firstname"].value;
    var y = document.forms["test"]["email"].value;
    if (x == "") {
     document.getElementById('error').innerHTML = "Name must be Filled!";
     return false;
    }
    if (y == "") {
     document.getElementById('error').innerHTML = "Email must be Filled!";
     return false;
    }
    var at = y.indexOf("@");
    var dot = y.lastIndexOf(".");
    if (at < 1 || dot < 4 || at > dot ) {
     document.getElementById('error').innerHTML = "Enter a valid email";
     return false;
    }
   }
  </script>
 </head>
 <body>
  <form name="test" method="post" onsubmit = 'return check()'>
   <input type="text" name="firstname" placeholder="Enter a name"/>
   <input type="text" name="email" placeholder="Enter your mail"/>
   <input type="submit" value="Send"/>
  </form>
  <p id="error"></p>
 </body>
</html>

Hey that's not Aello! its Hello..

Hello This is Sagar Devkota. Studying Bachelor of Software Engineering at Pokhara University. I know something about Linux, Android, Java, Nodejs, Unity3D and 3 dots :)

1 comment: Leave Your Comments

  1. ” end result of|as a result of} 3D printers will doubtless be so interwoven in our every day lives. Today, youngsters are being taught about 3D printing in elementary faculty, heaps of|and a lot of} local libraries at present have the machines out there, as do shops like UPS and Staples. The advances in drugs are arguably amongst some of the the} most fun, with scientists in a position to} create prosthetics and implants through 3D printing. They can also Cat Toys create precise physique elements like ears from stem cells, collagen and structural proteins within the human physique called fibrin; this course of recognized as|is called|is named} bioprinting, though much of it is still within the testing phases. Additionally, researchers can take a look at prescription drugs simply and ethically with tissue created from 3D printers.

    ReplyDelete