Cusotm function and 'required' needed for empty fields

13 views
Skip to first unread message

Rolf Herbert

unread,
Jul 14, 2014, 8:00:42 AM7/14/14
to moof...@googlegroups.com
Hi all,

I am using a custom function so that I can implement a 'THIS OR THAT' type check.

I have two fields and one OR the other OR both need to be filled in.

The issue is that if I dont use the required class an empty field, though returned as false by my custom function, is not counted as a validation fail when the form is submitted.

If I use the 'required' class then it confuses the users and also means I have to add/remove this class between the two fields depending on if they are empty or contain the right stuff.

Am I missing something here..?


Form

        <input name="pHourCredits" type="text" id="pHourCredits" class="validate['@checkHours']" size="4" /><span class="inputAfter">days</span> 
        OR
        <input name="pHourCreditsHours" type="text" id="pHourCreditsHours" class="validate['@checkHours']" size="4" /><span class="inputAfter">hours</span> 



custom function 'should' always invalidate the form

function checkHours(el){

el.errors.push("You must enter either the number of days or total number of hours.");
    return false;

}

Any ideas without going through the hula of adding the required class on submition then removing it and so on

Mar Co

unread,
Feb 9, 2015, 4:39:00 AM2/9/15
to moof...@googlegroups.com
Hi, I'm experiencing the same.

I suspect there's no easy workaround, but I may be wrong.
Have you solved it anyhow?

Jun Zhang

unread,
Feb 9, 2015, 7:04:17 AM2/9/15
to moof...@googlegroups.com
Hi,

In FormCheck, you need to include the custom function name in input element by '%FunctionName' or '~FunctionName', instead of '@FunctionName'.

OneZ

--
You received this message because you are subscribed to the Google Groups "MooFloor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to moofloor+u...@googlegroups.com.
To post to this group, send email to moof...@googlegroups.com.
Visit this group at http://groups.google.com/group/moofloor.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages