Javascript to Validate element based on another element value

DataWarrior

New Member
First time posting on this forum. I use it constantly and have found some really cool tricks.
I have a form where the user selects an item from a List. The form is populated with data from the list. I then have two fields that are similar in name, (one is hidden) and the value of Field2 must exactly match the value of Field1. If they don't match I need to stop all processing and show some type of alert. If the fields are the same there would be no alert. In Field2 I have the javascript set to hide Field1 on load, hide error.jpg on load, show error.jpg if Field1 and Field2 don't match.
If I type the literal value {meter_entry___New_Meter_Number2 } in the Field2 box everything works. I need the value of Field1.
Unlike radio buttons and Check boxes these values will never repeat.
 
To get the value of field1 ...

Code:
var field1Val = Fabrik.getBlock('form_X').formElements.get('yourtable___field1').getValue();

Replace X with your numeric form ID. Replace yourtable___field1 with the full element name of field 1.

-- hugh
 
Thanks for your prompt response and please pardon me for being so late with a reply. I tried the code above but with my limited knowledge, no success. Quite possibly I didn't explain my situation well enough.
I have two fields, one will be prepopulated from a list. The user clicks a link in the list which takes them to a Form. The user enters the info in the 2nd field. The 2 fields must match exactly before they can continue.
I'm trying some tricks to hide Field1 and show an error icon if they don't match. Maybe I could hide the submit button if they don't match.
 
We can't really help with coding in Community support. If you'd like to take out a support subscription, we can write that code for you.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top