How do I make wordpress comment fields required?
Here is my form:
<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform" class="validate">
<?php if($user_ID) : ?>
<?php else : ?>
<div class="label_container">
<div class="left">
<label for="author" class="label label_name">Name*</label>
</div>
<div class="right">
<label for="email" class="label label_email">Email*</label>
</div>
</div>
<div class="input_container">
<input id="name" name="author" class="required input_text input_name" type="text" value="" />
<input id="email" name="email" class="required input_text email input_email" type="text" value="" />
</div>
<?php endif; ?>
<div class="label_container">
<label for="comment" class="label label_comment">Comment</label>
</div>
<textarea id="comment_box" class="required input_comment" name="comment" cols="40" rows="6"></textarea>
<p><input name="submit" class="input_submit" type="submit" id="submit" tabindex="5" value="Submit Comment" />
<input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" /></p>
<input type="hidden" id="redirect_to" name="redirect_开发者_如何转开发to" value="<?php echo get_bloginfo('wpurl');?>/comment">
<?php do_action('comment_form', $post->ID); ?>
</form>
I have required fields on all inputs, but it is only working on the comment text field.
Any ideas?
you can actually control that from the settings
discussion tab
in the wp-admin
panel.
make sure to check Comment author must fill out name and e-mail
. that should do it.
is this what you are looking for?
if you want client side validation then use
http://bassistance.de/jquery-plugins/jquery-plugin-validation/
and if you want server side validation then use php
like
if(empty($_POST['email']))
{
//show error msg
}else{
//add comment
}
精彩评论