Witam, szukałem w intercienie, ale nie łapie tego, moze jakby mi ktos pokazał na przykładzie bardziej bym to zrozumiał. Mianowicie mam taki skrypt rejestracji php/js:
<?php
if (isset($_POST['rejestruj'])) {
$login = $_POST['login'];
$haslo = $_POST['haslo'];
$email = $_POST['email'];
$ciag_login = '/^[A-Za-z0-9]+$/D';
$ciag_email = '/^[a-zA-Z0-9\.\-_]+\@[a-zA-Z0-9\.\-_]+\.[a-z]{2,8}$/D';
if (((strlen($login))<3
) || ((strlen($login))>20
)) $bledy[0
] = true; if (!(preg_match($ciag_login,$login))) $bledy[1
] = true; if (((strlen($haslo))<5
) || ((strlen($haslo))>30
)) $bledy[2
] = true; if (!(preg_match($ciag_email,$email))) $bledy[3
] = true;
{
$pdo = new PDO('mysql:host=localhost;dbname=michat34', 'michat34', 'mud305000');
$stmt = $pdo->prepare('INSERT INTO uzytkownicy (login,haslo,email,data1) VALUES (:login,:haslo,:email,:data1)');
$stmt->bindValue(':login',$login,PDO::PARAM_STR);
$stmt->bindValue(':haslo',$haslo,PDO::PARAM_STR);
$stmt->bindValue(':email',$email,PDO::PARAM_STR);
$stmt->bindValue(':data1',date("Y-m-d"),PDO
::PARAM_STR);
$ilosc = $stmt->execute();
echo 'Pomyslnie zarejestrowano'; } else
{
if (isset($bledy[0
])) echo '<li>Login musi mieć min. 3 znaki i maks. 20 znaków</li>'; if (isset($bledy[1
])) echo '<li>Login może zawierać tylko cyfry oraz małe i duże litery</li>'; if (isset($bledy[2
])) echo '<li>Hasło musi mieć min. 5 znaków i maks. 30 znaków</li>'; if (isset($bledy[3
])) echo '<li>Niepoprawny adres e-mail</li>'; }
}
Rejestracja
<form action="index.php" method="post"> <tr><td>Login:
</td><td><input type="text" name="login" id="login" autocomplete="off" tabindex="1" class="reg"></td><td><input type="text" name="login_stan" id="login_stan" size="100" class="stan" readonly></td></tr> <tr><td>Hasło:
</td><td><input type="password" name="haslo" id="haslo" autocomplete="off" tabindex="2" class="reg"></td><td><input type="text" name="haslo_stan" id="haslo_stan" size="100" class="stan" readonly></td></tr> <tr><td>E-mail:
</td><td><input type="text" name="email" id="email" autocomplete="off" tabindex="3" class="reg"></td><td><input type="text" name="email_stan" id="email_stan" size="100" class="stan" readonly></td></tr> <input type="submit" name="rejestruj" value="Rejestruj">
<script type="text/javascript">
var login = document.getElementById('login');
var login_stan = document.getElementById('login_stan');
var haslo = document.getElementById('haslo');
var haslo_stan = document.getElementById('haslo_stan');
var email = document.getElementById('email');
var email_stan = document.getElementById('email_stan');
function sprawdz_login ()
{
var ciag = /^([A-Za-z0-9])+$/;
if (login.value.length == 0)
{
login.style.borderColor="black";
login_stan.style.color="black";
login_stan.value='';
} else if ((login.value.length < 3) || (login.value.length > 20))
{
login.style.borderColor="red";
login_stan.style.color="red";
login_stan.value='Długość loginu musi wynosić min. 3 znaki i maks. 20 znaków';
} else if (!(ciag.test(login.value)))
{
login.style.borderColor="red";
login_stan.style.color="red";
login_stan.value='Login może zawierać jedynie cyfry oraz duże i małe litery (bez polskich znaków)';
} else
{
login.style.borderColor="green";
login_stan.style.color="green";
login_stan.value='OK';
}
}
function sprawdz_haslo ()
{
if (haslo.value.length == 0)
{
haslo.style.borderColor="black";
haslo_stan.style.color="black";
haslo_stan.value='';
} else if ((haslo.value.length < 5) || (haslo.value.length > 30))
{
haslo.style.borderColor="red";
haslo_stan.style.color="red";
haslo_stan.value='Długość hasła musi wynosić min. 5 znaków i maks. 30 znaków';
} else
{
haslo.style.borderColor="green";
haslo_stan.style.color="green";
haslo_stan.value='OK';
}
}
function sprawdz_email ()
{
var ciag = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,8}$/;
if (email.value.length == 0)
{
email.style.borderColor="black";
email_stan.style.color="black";
email_stan.value='';
} else if (!(ciag.test(email.value)))
{
email.style.borderColor="red";
email_stan.style.color="red";
email_stan.value='Podaj poprawny e-mail';
} else
{
email.style.borderColor="green";
email_stan.style.color="green";
email_stan.value='OK';
}
}
login.onchange = sprawdz_login;
haslo.onchange = sprawdz_haslo;
email.onchange = sprawdz_email;
</script>
I chcialbym zeby napisy Pomyslnie Zarejestrowano i Wystapiły Błedy (wraz z bledami) wyswietlały sie z efektem FADE IN. mógłby mi to ktos wkleić do kodu? pozdrawiam
Ten post edytował michat34 30.09.2012, 22:31:36