Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html><head>
- <meta http-equiv="content-type" content="text/html; charset=UTE-8">
- <style>
- input {
- border: 2px solid #666;
- </style>
- <meta content="IE=11.0000" http-equiv="X-UA-Compatible">
- <meta charset="utf-8">
- <title>Formularz</title>
- <script>
- function wyslij(){
- if (document.getElementById("mezczyzna").checked == true) {
- plec = "mężczyzna";
- } else if (document.getElementById("kobieta").checked == true) {
- plec = "kobieta";
- } else {
- plec = false;
- }
- zaintersowania = new Array();
- if (document.getElementById("sport").checked == true) { zaintersowanie1 = "sport";
- } else { zaintersowanie1 = "";
- }
- if (document.getElementById("muzyka").checked == true) {
- zaintersowanie2 = "muzyka";
- } else { zaintersowanie2 = "";
- }
- if (document.getElementById("literatura").checked == true) {
- zaintersowanie3 = "literatura";
- } else { zaintersowanie3 = "";
- }
- if (document.getElementById("podroze").checked == true) {
- zaintersowanie4 = "podroze";
- } else { zaintersowanie4 = "";
- }
- if (document.getElementById("informatyka").checked == true) {
- zaintersowanie5 = "informatyka";
- } else { zaintersowanie5 = "";
- }
- imie = document.getElementById("imie");
- nazwisko = document.getElementById("nazwisko");
- miejsce = document.getElementById("zamieszkanie");
- wiadomosc = document.getElementById("wiadomosc");
- waliduj();
- }
- function reset() {
- document.getElementById("imie").value = " "; document.getElementById("nazwisko").value = " "; document.getElementById("mezczyzna").checked = false; document.getElementById("kobieta").checked = false; document.getElementById("sport").checked = false; document.getElementById("muzyka").checked = false; document.getElementById("literatura").checked = false; document.getElementById("podroze").checked = false; document.getElementById("zamieszkanie").selectedIndex = 0; document.getElementById("wiadomosc").value = " ";
- }
- function waliduj() {
- var wszystkoOK = true;
- var errors = "Musisz uzupełnić następujące pola: <br>";
- if(imie.value == "") {
- errors += "- Imie <br>";
- wszystkoOK = false;
- imie.style.borderColor = "red";
- }
- if(nazwisko.value == "") {
- errors += "- Nazwisko <br>";
- wszystkoOK = false;
- nazwisko.style.borderColor = "red";
- }
- if(miejsce.value == "") {
- errors += "- Zamieszkanie <br>";
- wszystkoOK = false;
- miejsce.style.borderColor = "red";
- }
- if(plec == false) {
- errors += "- Płeć <br>";
- wszystkoOK = false;
- }
- if(miejsce.selectedIndex == 0) {
- errors += "- Miejsce zamieszkania <br>";
- wszystkoOK = false;
- miejsce.style.borderColor = "red";
- }
- if(zaintersowanie1 == "" && zaintersowanie2 == "" && zaintersowanie3 == "" && zaintersowanie4 == "" && zaintersowanie == "") {
- errors += "- Przedmioty <br>";
- wszystkoOK = false;
- }
- if(wiadomosc.value == "") {
- errors += "- Wiadomość <br>";
- wszystkoOK = false;
- wiadomosc.style.borderColor = "red";
- }
- if(wszystkoOK != true) { document.getElementById("errors").innerHTML = errors;
- } else {
- document.write("Formularz uzupełniono pomyślnie:<br><hr><h2>Podsumowanie</h2><br><hr>");
- document.write("Imiona i nazwisko: " + imie.value + " " + nazwisko.value + "<br>");
- document.write("Płeć: " + plec + "<br>");
- document.write("Przedmioty: " + zaintersowania +
- "<br>");
- document.write("Klasa: " + miejsce.value+"<br>");
- document.write("Zainteresowania: " + wiadomosc.value + "<br>")} };
- </script>
- <meta name="GENERATOR" content="MSHTML 11.00.9600.18125"></head>
- <body>Imię:
- <input id="imie" type="text">
- <br> Nazwisko:
- <input id="nazwisko" type="text">
- <br>Płeć: Mężczyzna
- <input name="a1" id="mezczyzna" type="radio"> Kobieta
- <input name="a1" id="kobieta" type="radio" value="kobieta"><br>Przedmioty:
- Biologia
- <input id="sport" type="checkbox"> Geografia
- <input id="muzyka" type="checkbox"> Historia
- <input id="literatura" type="checkbox"> Fizyka
- <input id="podroze" type="checkbox">Informatyka
- <input id="informatyka" type="checkbox">
- <br>Klasa:
- <select id="zamieszkanie">
- <option selected="selected">----------
- </option>
- <option>1 AI</option> <option>2 AI</option> <option>3 AI</option> <option>4 AI</option></select>
- <br>Zainteresowania:<br>
- <textarea id="wiadomosc"></textarea>
- <br> <input id="wyslij" onclick="wyslij()"
- type="button" value="Wyślij"> <div id="errors"></div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement