dimanche 5 avril 2015

Adding Checkbox Validation to PHP Registration Form

I'm trying to add a checkbox validation to the form in this PHP file:



<?php?>
<?php get_header(); ?>
<?php if(get_option('users_can_register')) { ?>
<div class="column eightcol">
<script>
document.getElementById("form-invite").onsubmit = function() {
return this.rules.checked;
}
</script>
<form class="ajax-form formatted-form" id="form-invite" action="<?php echo AJAX_URL; ?>" method="POST">
<div class="message"></div>
<div class="column sixcol">
<div class="field-wrap">
<input type="text" name="user_login" placeholder="<?php _e('Username', 'lovestory'); ?>" />
</div>
</div>
<div class="column sixcol last">
<div class="field-wrap">
<input type="text" name="user_email" placeholder="<?php _e('Email', 'lovestory'); ?>" />
</div>
</div>
<div class="clear"></div>
<div class="column sixcol">
<div class="field-wrap">
<input type="password" name="user_password" placeholder="<?php _e('Password','lovestory'); ?>" />
</div>
</div>
<div class="column sixcol last">
<div class="field-wrap">
<input type="password" name="user_password_repeat" placeholder="<?php _e('Repeat Password','lovestory'); ?>" />
</div>
</div>
<a href="#" class="button submit-button"><?php _e('Register', 'lovestory'); ?></a>
<div class="loader"></div>
<input type="hidden" name="user_action" value="register_user" />
<input type="hidden" class="nonce" value="<?php echo wp_create_nonce(THEMEX_PREFIX.'nonce'); ?>" />
<input type="hidden" class="action" value="<?php echo THEMEX_PREFIX; ?>update_user" />
</form>
</div>
<?php } ?>
<div class="column fourcol last">
<?php if(get_option('users_can_register')) { ?>
<div class="section-title">
<h1><?php _e('Sign In', 'lovestory'); ?></h1>
</div>
<?php } ?>
<form class="ajax-form formatted-form" action="<?php echo AJAX_URL; ?>" method="POST">
<div class="message"></div>
<div class="field-wrap">
<input type="text" name="user_login" placeholder="<?php _e('Username', 'lovestory'); ?>" />
</div>
<div class="field-wrap">
<input type="password" name="user_password" placeholder="<?php _e('Password', 'lovestory'); ?>" />
</div>
<a href="#" class="button submit-button form-button"><?php _e('Sign In', 'lovestory'); ?></a>
<div class="loader"></div>
<input type="hidden" name="user_action" value="login_user" />
<input type="hidden" class="nonce" value="<?php echo wp_create_nonce(THEMEX_PREFIX.'nonce'); ?>" />
<input type="hidden" class="action" value="<?php echo THEMEX_PREFIX; ?>update_user" />
</form>
</div>
<div class="clear"></div>
<?php
query_posts(array(
'post_type' => 'page',
'meta_key' => '_wp_page_template',
'meta_value' => 'template-register.php'
));

while(have_posts()) {
the_post();
echo '<br />';
the_content();
break;
}
?>
<?php get_footer(); ?>


I need the submit function to execute only after the checkbox has been checked. So far every time I attempt to add this feature the form goes through even if the checkbox is not checked. Please advise. Thanks.





Aucun commentaire:

Enregistrer un commentaire