Validation by javascript on Save button

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Validation by javascript on Save button

pouyan
I would like to add a java script on save button to validate an edit box for email is not empty,
and if it is empty stay in form and not go to next step

I got following error on log and it seems
ERROR XFormsServer  -     |Unable to run a two-pass submission and xf:load within a same action sequence.


properties-local.xml:

      <property as="xs:string" name="oxf.fr.detail.process.save-draft.legal.*" >
          confirm(message = "Please confirm that you would like to submit your data.")
         then navigate(uri="javascript:myjavascript()")
         then save
         .............
      </property>


orbeon form source xml: 
   <xh:head>
        <xxf:script ev:event="xforms-ready">
                        function myjavascript() {
                           if (ORBEON.xforms.Document.getValue('plh_personal_information_email-control') = '')
                                return "Email address can't empty";
                        }
        </xxf:script>
Reply | Threaded
Open this post in threaded view
|

Re: Validation by javascript on Save button

Alessandro  Vernet
Administrator
Hi Pouyan,

Is the form created with Form Builder or running within Form Runner?
If it is, are you referring to the standard "save" button? Are you
saying that this is a "save draft" button, so you're OK with some data
in the form being invalid, but would like at least the email to be
there?

Alex

On Wed, Apr 1, 2015 at 7:17 PM, pouyan <[hidden email]> wrote:

> I would like to add a java script on save button to validate an edit box for
> email is not empty,
> and if it is empty stay in form and not go to next step
>
> I got following error on log and it seems
> ERROR XFormsServer  -     |Unable to run a two-pass submission and xf:load
> within a same action sequence.
>
>
> *properties-local.xml:*
>
>       <property as="xs:string"
> name="oxf.fr.detail.process.save-draft.legal.*" >
>           confirm(message = "Please confirm that you would like to submit your
> data.")
>          then navigate(uri="javascript:myjavascript()")
>          then save
>          .............
>       </property>
>
>
> *orbeon form source xml:*
>    <xh:head>
>         <xxf:script ev:event="xforms-ready">
>                         function myjavascript() {
>                            if
> (ORBEON.xforms.Document.getValue('plh_personal_information_email-control') =
> '')
>                                 return "Email address can't empty";
>                         }
>         </xxf:script>
>
> --
> View this message in context: http://discuss.orbeon.com/Validation-by-javascript-on-Save-button-tp4659746.html
> Sent from the Orbeon Forms community mailing list mailing list archive at Nabble.com.
>
> --
> You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> To post to this group, send email to [hidden email].

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Validation by javascript on Save button

pouyan
Hi Alex

The form is created by form builder , As you said it is "save draft" button and I am ok with some data
in the form being invalid, but would like at least the email to be
there

Thx
Pouyan
Reply | Threaded
Open this post in threaded view
|

Re: Validation by javascript on Save button

Alessandro  Vernet
Administrator
Hi Pouyan,

At this point, this type of partial validation isn't supported. So you can only either validate the form, or not validate it.

If you really need to do this, I imagine you could add a button that runs your JavaScript doing the validation with navigate(uri = "javascript: ..."), and your own JavaScript could, after checking that the email was entered, simulate a click on a button that does the save, but that you hide from the UI with CSS. (And note that this wouldn't be fully "secure", as the validation being done in JavaScript, users could get around your validation by doctoring the code sent to the browser.)

Alex

On Thu, Apr 2, 2015 at 5:40 PM pouyan <[hidden email]> wrote:
Hi Alex

The form is created by form builder , As you said it is "save draft" button
and I am ok with some data
in the form being invalid, but would like at least the email to be
there

Thx
Pouyan


--
View this message in context: http://discuss.orbeon.com/Validation-by-javascript-on-Save-button-tp4659746p4659752.html
Sent from the Orbeon Forms community mailing list mailing list archive at Nabble.com.

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet