Я новичок здесь, я работаю над регистрационной формой и пытаюсь понять, почему я не могу сделать поле «Имя» обязательным. Электронная почта и все остальное, кажется, работает нормально. Что мне не хватает? Спасибо
это то, что у меня есть для signup.js
$(document).ready(function() {
$("#signup-form").submit(function(e){
e.preventDefault();
var $form = $(this),
name = $form.find('input[name="name"]').val(),
email = $form.find('input[name="email"]').val(),
url = $form.attr('action');
$.post(url, {name:name, email:email},
function(data) {
if(data)
{
if(data=="Some fields are missing.")
{
$("#status").text("Please fill in your name and email.");
$("#status").css("color", "red");
}
else if(data=="Invalid name.")
{
$("#status").text("Please fill in your name.");
$("#status").css("color", "red");
}
else if(data=="Invalid email address.")
{
$("#status").text("Please check your email address.");
$("#status").css("color", "red");
}
else if(data=="Invalid list ID.")
{
$("#status").text("Your list ID is invalid.");
$("#status").css("color", "red");
}
else if(data=="Already subscribed.")
{
$("#status").text("You're already subscribed!");
$("#status").css("color", "red");
}
else
{
$("#status").text("You're subscribed! Please check your email for confirmation.");
$("#status").css("color", "green");
}
}
else
{
alert("Sorry, unable to subscribe. Please try again later!");
}
}
);
});
});
В файле html есть следующее:
<form action="signup.php" method="POST" accept-charset="utf-8" name="signup-form" id="signup-form" class="sign_form" >
<label for="Silver">Get Notified</label>
<div>
<input type="text" name="name" value="" placeholder="Full Name" class="name" />
<input type="text" name="email" value="" placeholder="Email" class="email" />
<input type="submit" value="➜" id="submit-btn" class="submit" />
</div>
<label id="status"></label>
</form>
и файл signup.php:
<?php
$submit_url = 'http://www.domain.com/signup';
$list = 'list010101';
//POST variables
$name = $_POST['name'];
$email = $_POST['email'];
//subscribe
$postdata = http_build_query(
array(
'name' => $name,
'email' => $email,
'list' => $list,
'boolean' => 'true'
)
);
$opts = array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata));
$context = stream_context_create($opts);
$result = file_get_contents($submit_url.'/subscribe', false, $context);
echo $result;
?>
required
верно? Часть HTML, пожалуйста? - person Iqbal Fauzi   schedule 18.04.2014