Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8"/>
- <script>
- function fcode(x){
- var pattern = /^\d{2}\-\d{3}$/;
- if (!x.value.match(pattern)) {
- alert("Niepoprawny format kodu pocztowego.");
- x.value = "";
- }
- }
- function fmail(x){
- var pattern = /^\w{1,30}@{1}\w{1,15}\.{1}[a-z]{1,3}$/;
- if (!x.value.match(pattern)) {
- alert("Niepoprawny format adresu e-mail.");
- x.value = "";
- }
- }
- function freal(x){
- var pattern = /^[0-9]{1,2}\.{1}[0-9]{1,2}$/;
- if (!x.value.match(pattern)){
- alert("Niepoprawny format liczby rzeczywistej.");
- x.value = "";
- }
- else{
- if (x.value<10 || x.value>30){
- alert("Liczba musi miescic sie w przedziale od 10 do 30.");
- x.value = "";
- }
- }
- }
- function fdayofweek(){
- var d = new Date();
- var currentDay = d.getDay();
- var x = document.getElementById("dow").value;
- if (x == currentDay) dow.disabled = true;
- else{
- var choice = confirm("Wybrany dzien rozni sie od dzisiejszego. Czy chcesz wprowadzić zmiany?");
- if (choice == true) dow.value = 0;
- else dow.disabled = true;
- }
- }
- function fsubmit(){
- if (document.getElementById("x").checked == false){
- alert("Nie potwierdziles zgody na przetwarzanie danych osobowych.");
- document.getElementById("x").focus();
- return false;
- }
- if(document.code.value == ''){
- alert("Kod pocztowy jest wymagany.");
- return false;
- }
- else if(document.mail.value == ''){
- alert("Adres e-mail jest wymagany.");
- return false;
- }
- else if (document.real.value == ''){
- alert("Wartosć jest wymagana.");
- return false;
- }
- return true;
- }
- </script>
- </head>
- <body>
- <form onsubmit="return fsubmit(this)" method="post">
- Podaj kod pocztowy w formacie CC-CCC:
- <input type="text" name="code" maxlength="6" onBlur="fcode(this)"/><br/><br/>
- Podaj adres e-mail w formacie adres@dowolna.domena:
- <input type="text" name="mail" maxlength="50" onBlur="fmail(this)"/><br/><br/>
- Podaj dowolną liczbę rzeczywistą z przedziału od 10 do 30:
- <input type="text" name="real" onBlur="freal(this)"/><br/><br/>
- Wybierz dzień tygodnia:<br/>
- <select id="dow" name="dayofweek" size="1" onchange="fdayofweek(this)">
- <option value="0" label=" "/>
- <option value="1"/>Poniedziałek
- <option value="2"/>Wtorek
- <option value="3"/>Środa
- <option value="4"/>Czwartek
- <option value="5"/>Piątek
- <option value="6"/>Sobota
- <option value="7"/>Niedziela
- </select><br/><br/>
- <input type="checkbox" id="x"/>
- <label for="x">Wyrażam zgodę na przetwarzanie moich danych osobowych.</label><br/><br/>
- <input type="submit"/>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement