· 5 years ago · Apr 07, 2020, 10:22 AM
1<!DOCTYPE HTML>
2<html lang="pl">
3<head>
4 <meta charset="utf-8" />
5 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
6
7 <title></title>
8
9
10</head>
11
12<body>
13<script>
14
15 var pin = /^[A-Z][a-z]+\s[A-Z][a-z]+$/;
16 var pk = /^[0-9]{2}-[0-9]{3}$/;
17 var pe = /^[a-z0-9]+@gmail.com$/;
18
19 var im = "";
20 var ko ="";
21 var ma = "";
22
23 function f(){
24
25 var imieinazwisko = document.getElementById("imieinazwisko").value;
26 var kod = document.getElementById("kod").value;
27 var mail = document.getElementById("mail").value;
28
29 if (pin.test(imieinazwisko)){
30 im = "poprawne";
31 }
32 else{
33 im = "błedne";
34 }
35 if (pk.test(kod)){
36 ko = "poprawny";
37 }
38 else{
39 ko = "błedny";
40 }
41 if (pe.test(mail)){
42 ma = "poprawny";
43 }
44 else{
45 ma = "błędny";
46 }
47
48 alert("Imie i nazwisko: "+im+"\n"+"Kod pocztowy: "+ko+"\n"+"Email w domenie @gmail.com: "+ma+"\n");
49 }
50
51</script>
52 <form>
53 <label for="imieinazwisko">Imie i nazwisko:</label><br>
54 <input type="text" id="imieinazwisko" name="imieinazwisko"><br>
55 <label for="kod">Kod Pocztowy:</label><br>
56 <input type="text" id="kod" name="kod"><br>
57 <label for="mail">Email w domenie @gmail.com:</label><br>
58 <input type="text" id="mail" name="mail"><br>
59</form>
60<br><button type="button" onclick="f()">KLIK</button>
61</body>
62</html>