提交表单时,如何验证所有页面,而不仅仅是当前页面?
首先,我使用 Form Builder 在 Orbeon Forms 中创建了一个表单。接下来,我将其设为多页表单,如 创建中所述使用表单生成器的向导或多页表单。
我面临的问题是,提交表单时,验证仅发生在当前可见的部分。提交时,我希望验证所有部分,即使只有一个部分可见。实现这一目标的最佳方法是什么?
First I created a form in Orbeon Forms with Form Builder. Next I made it a multi-page form as described in Create a wizard or multi-page form with Form Builder.
The problem I'm facing is that when submitting the form, validation only occurs on the currently visible sections. When submitting, I would like all sections to be validated even though only one section may be visible. What would be the best way to achieve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议您更改“下一步”按钮的代码,这样如果当前页面出现错误,它就不会切换到下一页。您可以通过在“Next”按钮内的
上添加if
“guard”来实现此目的,内容如下:这也将使事情变得更容易用户:如果你让他们在第 1 页有错误时导航到第 2 页,当他们在第 2 页上尝试保存时,你必须以某种方式告诉他们错误出现在上一页上,并为他们提供一种方法导航到该页面。
I would recommend you change the code of your "Next" button so it doesn't switch to the following page if there are errors on the current page. You can do so by adding an
if
"guard" on the<xforms:setvalue>
inside the "Next" button, that reads:This will also make things easier for users: if you let them navigate to page 2 while there are errors on page 1, when they try to save while on page 2, you will somehow have to tell them that the error is on a previous page, and provide a way for them to navigate to that page.