我正在尝试对主 html 页面中的 php 表单验证中的某个给定错误进行动画处理。我的问题是我不知道如何传递错误以触发 jquery 脚本在浏览器页面的表单顶部滑动消息。
html-contact.php
<form method="post" name="contact_form" action="message_handler.php">
<input type="text" class="textbox" name="name" maxlength="12" />
<input type="text" class="textbox" name="last_name" maxlength="12" />
<input type="text" class="textbox" name="email" maxlength="40" />
<input type="text" class="textbox_2" name="title" maxlength="40" />
<textarea name="message" ></textarea>
<input type="submit" value="Send Form">
</form>
php - message_handler.php
$name = $last_name = $visitor_email = $title = $message = $about = $validation = '';
$name = $_POST['name'];
$last_name = $_POST['last_name'];
$visitor_email = $_POST['email'];
$title = $_POST['title'];
$message = $_POST['message'];
$about = $_POST['about'];
$validation = $_POST['validation'];
$errors = array();
if( empty($name) || empty($visitor_email) || empty($message) || empty($validation))
{
echo 'Required fields.';
}
jquery - general_script.js
$('.error_message').animate({'width':300}, {queue:false, duration:200});