You are viewing limited content. For full access, please sign in.

Question

Question

Forms Validation- turn off and on through jquery

asked on October 5, 2016 Show version history

Does anyone have javascript that would bypass all required fields validation on load?  I also would like to turn it back on when the form is submitted.  My issue is the tab order on required fields is off due to a lookup so I need to bypass that on load...

 

0 0

Replies

replied on October 5, 2016

Hi Terri,

Could you elaborate on what you mean by the "tab order on required fields is off due to a lookup"?

What's the current (undesired) behavior and what would you like to happen instead?

Also, what are the types of the fields currently marked as required (Single Line, Address, etc.)?

0 0
replied on October 6, 2016

I can elaborate some. Terri and I are working on the same form. On the form in question, there is a lookup. The criteria for the lookup is the very first field on the form "Application ID" and it's a required field. The set of fields that the lookup is supposed to fill in do not show up on the form until around page 3 and they are just single line text fields that hold first name, last name, department ect. The fields that are filled in by the lookup are also required fields. When the form is launched, the form opens on page 3 and has focus on the first required field returned by the lookup. The expected and wanted behavior is for the form to open on page one and have focus on the very first required field in the form, which is also the criteria field for the lookup. The way it is now, the form opens, focus is briefly put on the first field, page one but a micro second later focus jumps down to page 3 "First Name" field.

0 0
replied on October 6, 2016 Show version history

Hi Chris,

Thanks for explaining in more detail. The crux of your issue is that the lookup is running when the page loads with an empty string as its parameter - since nothing is returned, it then tries to write blank values into the return fields. Required fields don't accept blank values as valid, so the invalid input focus code is triggered.

I think in this case you can utilize Field Rules to achieve the desired behavior. Try setting up the following, which will cause the Page 3 lookup-filled fields to be hidden (and un-required) by Forms onload:

As soon as a value is entered for the lookup criteria of Application ID, they'll show up and be required.

 

Something else you could do is have the lookup populate a set of non-required permanently hidden fields mirroring First/Last/Dept/etc., and have JavaScript triggered by an onchange event that writes the input of each of those fields into its visible and required counterpart if the input is not an empty string.

 

To protect against actual null or blank values that may be in the database you're doing lookups from, you might also want to replace the lookup with a stored procedure like the one below and call the stored procedure from Forms instead.

CREATE PROCEDURE [dbo].[MyStoredProcedure] @applicationID nchar(9)

AS
BEGIN
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	SELECT [first_name_column] AS firstName, [last_name_column] AS lastName, [department_column] AS department
	FROM [dbo].[Table]
	WHERE [application_id_column] = @applicationID AND [application_id_column] IS NOT NULL AND [application_id_column] != ''
END

 

0 0
replied on October 7, 2016

Thank you Samuel, this was very helpful

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.