function validateOnSubmit(dopw) {
dopw = dopw || 0;
var errs=0;
// execute all element validations in reverse order, so focus gets
// set to the first one in error.
if(dopw==1){
if (!validatePasswords (document.forms.frmRegistration.user_password, document.forms.frmRegistration.user_password_confirmation, 'inf_user_password', true)) errs += 1;
}
if (!validateEmail (document.forms.frmRegistration.user_email, 'inf_user_email', true)) errs += 1;
if (!validatePresent (document.forms.frmRegistration.user_lastname, 'inf_user_lastname')) errs += 1;
if (!validatePresent (document.forms.frmRegistration.user_firstname, 'inf_user_firstname')) errs += 1;
if (errs > 1) alert('There are fields that need correction before saving');
if (errs == 1) alert('There is a field that needs correction before saving');
return (errs==0);
};