Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

JavaScript interaction with Fields

Chris Erlich
1 decade ago Dec 01, 2011 10:52pm


first of all my apologies if this is the wrong forum. I thought “general help” fits best. If not, please feel free to move my post to a more appropriate one.
Here’s my problem:

I have a basic form with the following fields:

• First-Name
• Last-Name
• User-Name
• Passwort
• Type (e.g.: Admin, Master, User, Guest |more types can be added by the user)
• Date-of-Birth
• Telephone-Number

Since the user can add/change the “Type” I cannot hard-code rules. Therefore I want the user to be able to add Javascript to define his/her own rules. In this case the script should run every time ”Type” is changed.

For example something like this:

var a = form.getValue(Type);
if (a  ==Admin) {
   form.setMandatory(Telephone-Number, true);
   form.setMandatory(Date-of-Birth, true);
} else {
  Form.setVisibility(Telephone-Number, false);

Has anyone done something like this? Any suggestions where to start? Should I try to write my own libraries? Or should I use jQuery or something similar?

Any help is appreciated and thank you in advance,

Last updated on Dec, 22nd 2011
Tomi Virkki
1 decade ago Dec 12, 2011 8:35am
Chris Erlich
1 decade ago Dec 22, 2011 10:36pm