Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>Form</title>
- <style>
- body {
- background-color: #3e3e3e;
- color: #e3e3e3;
- }
- </style>
- </head>
- <body>
- <form name="form1" onsubmit="return weryfikacja()">
- Imie i nazwisko: <input type="text" name="imie">
- <br>
- Wiek: <input type="number" name="wiek">
- <br>
- <input type="submit" value="ok">
- </form>
- <form name="login" onsubmit="return logowanie()">
- Nazwa: <input type="text" name="nazwa"><br>
- Haslo: <input type="password" name="haslo"><br>
- <input type="submit" value="Zaloguj">
- </form>
- <script>
- //alert(document.getElementById("jeden").children[2].value);
- function weryfikacja(){
- var wiek = parseInt( document.forms['form1']['wiek'].value );
- if( isNaN(wiek) ){
- alert("Nie podales wieku!");
- return false;
- }
- if( wiek < 18 ){
- alert("Jestes nie pelnoletni");
- return false;
- }else {
- var imie = document.forms['form1']['imie'].value;
- alert("Witaj: " + imie);
- }
- }
- function logowanie(){
- var nickElem = document.forms['login']['nazwa'];
- var passElem = document.forms['login']['haslo'];
- if(nickElem.value.length < 3 ){
- nickElem.style.backgroundColor = "red";
- setTimeout( function(){
- nickElem.style.backgroundColor = "white";
- }, 500); //500ms = 0.5s
- return false;
- }
- if(passElem.value.length < 6 ){
- passElem.style.backgroundColor = "red";
- setTimeout( function(){
- passElem.style.backgroundColor = "white";
- }, 500); //500ms = 0.5s
- return false;
- }
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement