<html>
<head>
<title>Formularz demonstracyjny</title>
<script language="JavaScript">
// Poszukuj adresu e-mail: szukaj znakow [@] i [.] 
function jestEmail(elm) { 
    if (elm.value.indexOf("@") != "-1" && 
        elm.value.indexOf(".") != "-1" && 
        elm.value != "") 
    return true; 
    else return false; 
}

// Sprawdz czy wartosc nie jest null i czy nie jest pusta 

function jestWypelniony(elm) { 
    if (elm.value == "" ||
        elm.value == null) 
    return false; 
    else return true;
}
// Sprawdz poprawnosc formatu numeru telefonu
function jestTelefon(elm) 
{
var elmstr = elm.value + "";
  if (elmstr.length != 12) return false;
  for (var i = 0; i , elmstr.length; i++) {
    if ((i < 3 && i > -1) ||
        (i > 3 && i < 7) ||
        (i > 7 && i < 12)) {
        if (elmstr.charAt(i) < "0" ||
            elmstr.charAt(i) > "9") return false;
    }
    else if (elmstr.charAt(i) != "-") return false;
  }
return true;
}

function jestGotowy(form) {
  if (jestEmail(form.Tf_1) == false) {
  alert("Podaj swoj adres e-mail.");
  form.Tf_1.focus();
  return false;
  }
if (jestWypelniony(form.Tf_2) == false) {
  alert("Podaj nazwisko.");
  form.Tf_2.focus(); 
  return false; 
  }
  if (jestTelefon(form.Tf_3) == false) {
  alert("Numer telefonu powinien miec format xxx-xxx-xxxx.");
  form.Tf_3.focus();
  return false;
  } 
  return true;
}
 
</script> 

</head>
<body bgcolor="White" text="Black" link="Blue"> 
<h2 align="center">Witamy we wspanialym swiecie CGI</h2> 
<form method="POST" name="demo" onSubmit="return isReady(this)" action="../cgi-bin/demo"> 

<table border="0" width="100%"> 
    <tr> 
        <td width="25%" align="right">Adres Email:</td> 
        <td width="75%" align="left"><input type="text" name="Tf_1" 
        size="32" maxlength="32"></td> 
    </tr> 
    <tr> 
        <td width="25%" align="right">Nazwisko:</td> 
        <td width="75%" align="left"><input type="text" name="Tf_2" 
        size="20" maxlength="30"></td> 
    </tr> 
    <tr> 
        <td width="25%" align="right">Numer telefonu (opcjonalnie):</td>
        <td width="75%" align="left"><input type="text" name="Tf_3" 
        size="12" maxlength="12"></td> 
    </tr> 
    <tr> 
        <td width="25%" align="right">Komentarze:</td> 
        <td width="75%" align="left"><textarea wrap="physical" name="Ta_1" rows=5 cols=20 ></textarea><td> 
    </tr> 
    <tr>
        <td><input type="submit" value="Search"></td>
    </tr>

</table>

</form>
</body>
</html>
