Jump to content
  • 0

Validating User Input in Cascading Autocomplete Field


Student2017

Question

I have a dropdown where a student can select a University from a list of Universities.

Based on the user's University selection he/she enters the Course name (Cascading Autocomplete) and suggestions are made.

My question is how can I make sure that the user chooses a right suggestion and does not enter an incorrect value in the Course field? (Example: User types Nuclear Physics when that is not a Course option for his/her selected University)

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0
1 hour ago, Student2017 said:

I have a dropdown where a student can select a University from a list of Universities.

Based on the user's University selection he/she enters the Course name (Cascading Autocomplete) and suggestions are made.

My question is how can I make sure that the user chooses a right suggestion and does not enter an incorrect value in the Course field? (Example: User types Nuclear Physics when that is not a Course option for his/her selected University)

I would recommend using lookup table as  a datasource for form element, in this case, user will  be able to select only existing value from the list of available options.

Link to comment
Share on other sites

  • 0
6 hours ago, Mathilda said:

I would recommend using lookup table as  a datasource for form element, in this case, user will  be able to select only existing value from the list of available options.

I have a table of Universities and Courses linked together and I use this as a datasource for the University dropdown. Next, I made the Course field a Cascading Autocomplete based on the same table where the cascade is filtered by University Name and Autcomplete is filtered by Course Name.

The problem I have is that the form still accepts any random value the user enters in the Course field.

Is there a javascript code which I could use or something similar that displays an error if the user enters a Course that is not linked to the University he/she has chosen.

I could but do not want to use a dropdown because there will be 100+ values

Link to comment
Share on other sites

  • 0
On 7/21/2017 at 10:50 PM, Student2017 said:

I have a table of Universities and Courses linked together and I use this as a datasource for the University dropdown. Next, I made the Course field a Cascading Autocomplete based on the same table where the cascade is filtered by University Name and Autcomplete is filtered by Course Name.

The problem I have is that the form still accepts any random value the user enters in the Course field.

Is there a javascript code which I could use or something similar that displays an error if the user enters a Course that is not linked to the University he/she has chosen.

I could but do not want to use a dropdown because there will be 100+ values

You may create a relationship between tables and enable referential integrity. In this case, user will not be able to submit a value into the related table which doesn't exists in the parent table. You can find more info here

Link to comment
Share on other sites

  • 0
18 hours ago, Mathilda said:

You may create a relationship between tables and enable referential integrity. In this case, user will not be able to submit a value into the related table which doesn't exists in the parent table. You can find more info here

Thank you so much. I was struggling on how to approach this and this worked perfectly.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...