Forums

Get Validation working

aod2006 11 Nov, 2008
I am brand new to Chronoforms and just got my first form working. The only problem I have is I Don't know how to create two form items that have to be the same to work. Like a password field that needs to be the same before submitted or email/confirm e-mail fields that need to be the same before the user hits submit.

I also need the form to display a message if the two corresponding fields aren't the same.
Max_admin 11 Nov, 2008
Hi aod2006,

you can do this with JS, show me the 2 fields html you have!

Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
aod2006 12 Nov, 2008
<label class="cf_label">E-mail Address:</label><input class="cf_inputbox required validate-email" maxlength="150" size="30" id="text_13" name="text_13" type="text"></div><div class="clear"> </div></div><div  class="form_item"><div class="form_element cf_textbox"><label class="cf_label">Confirm E-mail Address:</label><input class="cf_inputbox required validate-email" maxlength="150" size="30" id="text_12" name="text_12" type="text">

<label class="cf_label">Choose a password:</label><input class="cf_inputbox required" maxlength="150" size="30" id="text_15" name="text_15" type="password"></div><div class="clear"> </div></div><div  class="form_item"><div class="form_element cf_password"><label class="cf_label">Confirm Password:</label><input class="cf_inputbox required" maxlength="150" size="30" id="text_16" name="text_16" type="password">


That is the code I found in the "Form Code" section for HTML. As you can probably see, I just need to make the two password fields to be the same and then the two email forms to be the same. If they aren't the same it would display a message telling the person to correct it.
Max_admin 12 Nov, 2008
Hi,

lets do this, #1- in the "form tag attachement" field in the genral tab, add :
 onSubmit="return Validate()"

#2- at the JS box, add :

function Validate(){
if(document.getElementById('text_13').value != document.getElementById('text_15').value){
alert('Your passwords do not match');
return false;
}else{
return true;
}
}


let me know!

Regards
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.