Thanks for your quick reply. I am not very good with modifying js so I thank you in advance for your patience.
I should have clarified. I am using the native Joomla Log In/Register module.
The form page is here:
Code:
<?php // no direct access
defined('_JEXEC') or die('Restricted access'); ?>
<script type="text/javascript">
<!--
Window.onDomReady(function(){
document.formvalidator.setHandler('passverify', function (value) { return ($('password').value == value); } );
});
// -->
</script>
<script language="javascript">
function myValidate(f) {
if (document.formvalidator.isValid(f)) {
f.check.value='';//send token
return true;
}
else {
alert('Some values are not acceptable. Please retry.');
}
return false;
}
</script>
<?php
if(isset($this->message)){
$this->display('message');
}
?>
<form action="<?php echo JRoute::_( 'index.php?option=com_user' ); ?>" method="post" id="josForm" name="josForm" class="form-validate" onSubmit="return myValidate(this);">
<?php if ( $this->params->def( 'show_page_title', 1 ) ) : ?>
<div class="componentheading<?php echo $this->escape($this->params->get('pageclass_sfx')); ?>"><?php echo $this->escape($this->params->get('page_title')); ?></div>
<?php endif; ?>
<table cellpadding="0" cellspacing="0" border="0" width="100%" class="contentpane">
<tr>
<td width="30%" height="40">
<label id="namemsg" for="name">
<?php echo JText::_( 'Name' ); ?>:
</label>
</td>
<td>
<input type="text" name="name" id="name" size="40" value="<?php echo $this->escape($this->user->get( 'name' ));?>" class="inputbox required" maxlength="50" /> *
</td>
</tr>
<tr>
<td height="40">
<label id="usernamemsg" for="username">
<?php echo JText::_( 'User name' ); ?>:
</label>
</td>
<td>
<input type="text" id="username" name="username" size="40" value="<?php echo $this->escape($this->user->get( 'username' ));?>" class="inputbox required validate-username" maxlength="25" /> *
</td>
</tr>
<tr>
<td height="40">
<label id="emailmsg" for="email">
<?php echo JText::_( 'Email' ); ?>:
</label>
</td>
<td>
<input type="text" id="email" name="email" size="40" value="<?php echo $this->escape($this->user->get( 'email' ));?>" class="inputbox required validate-email" maxlength="100" /> *
</td>
</tr>
<tr>
<td height="40">
<label id="pwmsg" for="password">
<?php echo JText::_( 'Password' ); ?>:
</label>
</td>
<td>
<input class="inputbox required validate-password" type="password" id="password" name="password" size="40" value="" /> *
</td>
</tr>
<tr>
<td height="40">
<label id="pw2msg" for="password2">
<?php echo JText::_( 'Verify Password' ); ?>:
</label>
</td>
<td>
<input class="inputbox required validate-passverify" type="password" id="password2" name="password2" size="40" value="" /> *
</td>
</tr>
<tr>
<td>
<label id="tos" for="tos2">
<?php echo JText::_( 'I have read the Terms of Service' ); ?>:
</label>
</td>
<td>
<input type="checkbox" id="tos2" name="tos2" size="40" value="" <?php echo 'class="required validate-checkbox"'; ?>/>{source}<a href="http://mydomain.com/index.php?option=com_content&view=article&id=5&Itemid=5" target="_blank"> I have agreed to the Terms of Service.</a>{/source}
</td>
</tr>
<tr>
<td colspan="2" height="40">
<?php echo JText::_( 'REGISTER_REQUIRED' ); ?>
</td>
</tr>
</table>
<button class="button validate" type="submit"><?php echo JText::_('Register'); ?></button>
<input type="hidden" name="task" value="register_save" />
<input type="hidden" name="id" value="0" />
<input type="hidden" name="gid" value="0" />
<?php echo JHTML::_( 'form.token' ); ?>
</form>
you can see I've added the BF Validate script on the top, under the forms validator script.
Added checkbox:
Code:
<tr>
<td>
<label id="tos" for="tos2">
<?php echo JText::_( 'I have read the Terms of Service' ); ?>:
</label>
</td>
<td>
<input type="checkbox" id="tos2" name="tos2" size="40" value="" <?php echo 'class="required validate-checkbox"'; ?>/>{source}<a href="http://mydomain.com/index.php?option=com_content&view=article&id=5&Itemid=5" target="_blank"> I have agreed to the Terms of Service.</a>{/source}
</td>
</tr>
The form tag already had an action so I added the onSubmit at the end:
Code:
<form action="<?php echo JRoute::_( 'index.php?option=com_user' ); ?>" method="post" id="josForm" name="josForm" class="form-validate" onSubmit="return myValidate(this);">
I am not sure where to put:
Code:
BFBehavior::formbfvalidation();
Also do I place this in it's own script tag? Should it be at the beginning of the page?
Code:
// this function is called when I need to validate a form. You could also check the token in the first IF before the return true.
var formValidate = function(form, msg) {
if (document.formvalidator.isValid(form)) {
return true;
}
else {
alert(msg);
}
return false;
};
I checked the js code from line 136 and I cut and pasted that right, woo, 1 out of 4
Thanks again for taking time to help.