Forums

Required field validation does not fire if field not touched

baalwww 19 Jan, 2009
I'm running the component version of v3. I have a number of fields that are required. If you tab to the field, and then attempt to tab out without typing, the error message appears below the field (this is mootools validation).

If you do not touch the field, and just click submit with any or all of the required fields empty, or if you complete some fields, but leave other required fields empty without touching them, no error message appears.
GreyHead 20 Jan, 2009
Hi baalwww,

The validation code is normally all checked on submission. It may not be happening for you because of some kind of JavaScript conflict or error.

Bob
baalwww 20 Jan, 2009
Hi. I found the problem, but not the solution. I have a graphical button that is used for submit instead of a submit button. So, instead of

<input type="submit" class="button">

I have

<a onclick="document.thisform.submit()" class="button">

If I use a submit button, the validation fires. If I use the graphic inside the link, it just submits without validation. Any thoughts?
baalwww 21 Jan, 2009
No, I was mistaken. It does not work in IE7 even with the normal submit button. Can someone please help? Perhaps explain to me how Chronoforms/mootools attaches itself to the submit process...because it's not happening in IE. The validation works field by field, but not if the form appears and submit is clicked with the required fields empty, so it's just the submit process that's broken.
GreyHead 21 Jan, 2009
Hi baalwww,

I don't think that document.thisform.submit() will do anything. You surely need the current form name or id in there which willb e something like ChronoContact_form_name

Bob
baalwww 21 Jan, 2009
No, what I'm saying is that I completely commented out the form.submit() with the graphic button from the form. I am back to just having a regular <input type="submit"> submit button, and the same problem. In IE7, validation only occurs when leaving the required field, not if the submit is clicked with empty required fields.
GreyHead 21 Jan, 2009
Hi baalwww,

The page works fine in FireFox and the validation work on Submit as it should.

In IE7 I have trouble getting the page to load - but when it does it doesn't validate. You almost certainly have a JavaScript conflict with something else on the page. There are at least 13 different scripts loading - I suggest that you disable them all and then put them back one by one until you locate the conflict (starting with the talking head!!)

Bob
GreyHead 21 Jan, 2009
Hi baalwww,

I can still see a couple of script snippets in the html that are doing something with the field validation - I don't think either of them are created by ChronoForms,

Bob

<script type="text/javascript">
Element.extend({
getInputByName1 : function(nome) {
el = this.getFormElements().filterByAttribute('name','=',nome)
return (el)?(el.length)?el[0]:el:false;
}
});
window.addEvent('domready', function() {
('first_name,last_name,mobile,email,description,00N80000002XknD').split(',').each(function(field){
$('ChronoContact_ContactUs').getInputByName1(field).addClass('required');
});
('email').split(',').each(function(field){
$('ChronoContact_ContactUs').getInputByName1(field).addClass('validate-email');
});
('URL').split(',').each(function(field){
$('ChronoContact_ContactUs').getInputByName1(field).addClass('validate-url');
});
('00N80000002XknD,00N80000002XX37,00N80000002WHmi,00N80000002WHmt').split(',').each(function(field){
$('ChronoContact_ContactUs').getInputByName1(field).addClass('validate-selection');
});
});
</script>
<script type='text/javascript'>
//<![CDATA[
function checkForm(theForm) {
    var checkvalue=true;
    var email=true;
    for (i=0; i<theForm.length; i++) {
        var oElement = theForm.elements[i];
        if (oElement.className=='required' && oElement.value=='') {
            checkvalue = false;
        }
    }
    if (checkvalue) email=checkEmail(theForm);
    if(!email) alert('The two email fields must match');
    else {if(!checkvalue) alert('Please fill in all required fields');};
    return checkvalue && email;
}
//]]>
</script>
baalwww 21 Jan, 2009
The first snippet absolutely is created by Chronoforms. It is not present in the form code or the article body.

I've removed the second snippet. Same error.
GreyHead 21 Jan, 2009
Hi baalwww,

Sorry, I'm out of ideas for the moment, maybe Max will have some suggestions.

Bob
Max_admin 21 Jan, 2009
Hi,

lets try to test again with a small form, 2 fields, name and email, because may be the "00N80000002XknD" kind of fields names are making problems, you can make a form using the wizard too and test with it, but use the wizard in Firefox please then test it in both FF and IE7

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.
baalwww 27 Jan, 2009
Max,

That's precisely what the issue was. This Sales Force(.com) allows the user to maintain a 'dictionary' of fields, all of which have normal field names. However, if the field is a pick list (select), for some reason internal to their processing, they generate id's / field names using some code that includes a numeric prefix. As a programmer, I understand why that's horrible. I'm having them look into whether this can be altered. Is there something that can be done on your end that would check for a field name beginning with a numeric, and if so, accounting for it in some way without dying?
GreyHead 27 Jan, 2009
Hi baalwww,

Coudl you use a look-up table in the backend to rename the field before passing them to SalesForce??

Bob

PS IIRC field names and ids starting with a number are invalid html - perhaps that might help them re-think.
baalwww 27 Jan, 2009
Hi Bob,

No backend as such...the form gets submitted directly to them, and since you attach the submit button, I don't know if I can do any post-validation pre-submit processing. But you are correct about the spec:

ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").

I'll send that to them.
This topic is locked and no more replies can be posted.