Код
<!DOCTYPE html>
<html>
<head>
<title>Jquery проверка формы</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<script src="http://code.jquery.com/jquery-1.8.1.min.js"></script>
<script>
$(document).ready(function(){
$("#registerForm").submit(function(){
var login = $("#login").val();
var password = $("#password").val();
var password2 = $("#password2").val();
if(login.length < 5 || login.length > 10)
{
alert('Логин может быть не менее 5 и не более 10 символов');
return false;
}
if(password !== password2)
{
alert('пароли не совпадают');
return false;
}
});
});
</script>
</head>
<body>
<div style="width: 500px; margin: 0 auto">
<form action="" method="post" id="registerForm">
<h1>регистрация</h1>
<input type="text" class="inputField" id="login" name="login" placeholder="Логин" />
<br />
<input type="password" class="inputField" id="password" name="password" placeholder="Пароль" />
<br />
<input type="password" class="inputField" id="password2" name="password2" placeholder="Подтверждение" />
<br />
<input type="email" class="inputField" id="email" name="email" placeholder="E-mail" />
<br />
<button type="submit" id="register" name="register">Регистрация</button>
</form>
</div>
</body>
</html>
Отредактировал: onotole, - 19.12.2013, 14:45