简体   繁体   English

Adobe表单的Java验证(单选按钮)

[英]Javascript validation of Adobe form (radio buttons)

I'm having difficulty (I'm new to JavaScript) figuring out a little validation in Adobe LiveCycle forms. 我很难(我是JavaScript新手)在Adobe LiveCycle表单中弄清楚一点验证。 I have a first choice (4 option) radio button, 2nd choice (same 4 options) and 3rd choice (same 4 options) where I'd like a validation to make sure the user doesn't enter the same result 3 times. 我有一个第一选择(4个选项)单选按钮,第二个选择(相同的4个选项)和第三个选择(相同的4个选项),我想进行验证以确保用户不会输入相同的结果3次。

I thought it would be something like: 我以为会是这样的:

event.rc = true;
if (  form1.#subform[0].FirstChoice.rawValue !=   form1.#subform[0].SecondChoice.rawValue ! &&  form1.#subform[0].FirstChoice.rawValue !=  form1.#subform[0].ThirdChoice.rawValue !)
{
    app.alert("You need three separate answers, you dimwit!");
    event.rc = false;
}

Evidently, I am being a dimwit and going about this all wrong, but I've drawn a blank. 显然,我是个昏昏欲睡的人,这一切都是错误的,但是我已经划清了空白。

I was thinking also along the lines of: 我也在考虑以下方面:

form1.#subform[0].FirstChoice.rawValue <>   form1.#subform[0].SecondChoice.rawValue ! &&  form1.#subform[0].FirstChoice.rawValue !<>  form1.#subform[0].ThirdChoice.rawValue !)

but I don't know where to go with it. 但我不知道该去哪里。

Help (please), thanks. 帮助(请),谢谢。

You are pretty close. 你很亲密 Try: 尝试:

if ((Select1.rawValue != null && Select1.rawValue == Select2.rawValue) || (Select2.rawValue != null && Select2.rawValue == Select3.rawValue) || (Select3.rawValue != null && Select1.rawValue == Select3.rawValue))
{
    app.alert("You need three separate answers, you dimwit!");
}

You need to cover the case where the Selections are not yet filled in. Select1, Select2, and Select3 are the RadioButton group. 您需要解决尚未填写选区的情况。Select1,Select2和Select3是RadioButton组。

I would put this as a calculation on a hidden field since you want it to recalculate whenever a change is made to the radio buttons. 我希望将此作为隐藏字段上的计算,因为您希望每当对单选按钮进行更改时就重新计算。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM