validation 'elf proef' on input.

I'd like to add an 'elf proef' (http://nl.wikipedia.org/wiki/Elfproef) validation to an input field in a backbase form. I added a behaviour to do the 'elf proef' and fire a valid/invalid event. The problem is, after the check and on submit the validate() method runs. The validate() method sets the field on 'valid' again.

Does anyone have an idea how to implement the 'elf proef' to a backbase form?

Can you post your code?

You mention firing an event but do you set the 'successful' property to false if the validation fails?
This property indicates whether the validation succeeded or failed.
If the successful property is false, then validate() will return false too.
Even if that resolves your problem, please do post your code. I know a lot of people are interested in how to implement a custom validation routine.

Hi, thanks for you reply. I

Hi, thanks for you reply.

I finally got some time to try your suggestion, but still it is not working. The validate() method still accepts the field, even when the succesfull property is set to false. Here is a summary of the code i wrote:

<!-- part of form: input field -->
<input bf:messagesRef='following-sibling::bf:messages' e:behavior='my:11Proef' name='BSN' type='text'/>

<!-- behaviour to do a check -->
        <d:behavior name="11Proef">
                        <d:property name="valid" /> <!-- denotes whether field is valid-->
                        <d:property name="virgin" /> <!-- denotes whether field has been changed before -->
                        <d:property name="successful" /> <!-- denotes whether field is ready for submission -->

                        <d:handler event="DOMNodeInsertedIntoDocument" type="application/javascript">
                                <![CDATA[
                                bb.setProperty(this, 'valid', false);
                                bb.setProperty(this, 'virgin', true);
                                bb.setProperty(this, 'successful', false);
                                ]]>
                        </d:handler>
                       
                        <d:handler event="blur" type="application/javascript">
                                <![CDATA[
                                if (myCheck(this.viewNode.value)) { //input value valid
                                        var oEvent = bb.document.createEvent('Events');
                                        oEvent.initEvent('valid', false, false);
                                        this.dispatchEvent(oEvent);
                                       
                                } else { //input value invalid
                                        var oEvent = bb.document.createEvent('Events');
                                        oEvent.initEvent('invalid', false, false);
                                        this.dispatchEvent(oEvent);
                                }
                                ]]>
                        </d:handler>

                        <d:handler event="valid" type="application/javascript">
                                <![CDATA[
                                bb.setProperty(this,'valid', true);
                                bb.setProperty(this,'virgin', false);
                                bb.setProperty(this,'successful',true);
                                ]]>
                        </d:handler>
                       
                        <d:handler event="invalid" type="application/javascript">
                                <![CDATA[
                                bb.setProperty(this,'valid', false);   
                                bb.setProperty(this,'virgin', false);  
                                bb.setProperty(this,'successful',false);
                                ]]>
                        </d:handler>

                </d:behavior>

validate method

Hi pdjong,

The 'successful' property is useful when you want to prevent some form field to be submitted. So, if there is no "name" attribute in the form field, this form field will never being submitted.
Note: Form field means inputText, comboBox, checkBox, etc

If you want to get rid of the validate method, by using your own checking you could overwrite the "validity" property of inputText.

You can see the pattern of "validity" property in forms/formsbase.xml (element:inputBase).

Hope this helps,

Andys

Thanks this helped me

Thanks this helped me out.

<!-- input field -->
<input bf:messagesRef='following-sibling::bf:messages' e:behavior='my:elfProefBSN' name='BSN' type='text'/>

<!-- behaviour -->
        <d:behavior name="elfProefBSN">
                        <d:property name="validity" >
                                <d:getter type="application/javascript">
                                <![CDATA[
                                        return elfProefBSN(); //do the elfProef (true/false)
                                ]]>
                                </d:getter>
                        </d:property>
</d:behaviour>