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

Question

Question

Entering numbers with/without hypens in look-up field

asked on July 6, 2017

I have a look-up field that accesses a database that has the numbers formatted like this 12-123-12-12345, as well as a description of that particular code.  I would like to enable people to enter the number code with or without hyphens.  Is this something I need to script?  If so, how?  

Note:  In the look-up field, info pulled shows both the number code and the description.  For example, "12-123-12-12345 test code" would be generated using the look-up.

 

0 0

Replies

replied on July 6, 2017 Show version history

To get a lookup working without enforcing the "-" formatting on the user input field, I think you'll need to create a second (hidden) field that actually handles the lookup. Then, do the following with JavaScript:

  1. Assign a "change" event to the input field (let's call this Field1
  2. On Field1 Change -
    • Retrieve the field/input value, for example
    • remove all "-" characters
    • format the value as desired (removing user-entered dashes will make this easier)
    • Update the value of Field2 with your formatted string
    • trigger the "change" event on Field2 (this will trigger the lookup)

 

There are several ways you could go about formatting the string through javascript, so you'll want to weigh your options and see which one you prefer.

If the user is entering just the code, in theory, you could also accomplish this using functions, but the formula would probably be ridiculously complex and wouldn't work if the input needs to have spaces.

0 0
replied on October 4, 2017

Due to the fact I am fairly new to coding, I've decided to leave this issue alone and make those entering information comply by entering the proper format.  

Jason, thank you for your response.

0 0
replied on January 7, 2020

Jason,

Could you provide an example of the JavaScript needed for this?

 

Thanks,

0 0
replied on January 7, 2020

Which piece of code are you looking for? I don't have actually any code that matches the specific scenario described above because it isn't something I've needed to do.

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

Sign in to reply to this post.