Stripping character from a field -...

User 1882563 Photo


Registered User
9 posts

I have a field for a Case number where the input would look like 4649706375-462 but I would like the subject line to only display 4649706375 stripping off the last 4 characters. I use the following syntax for the subject: <CASE:[CaseNumber]>

Can I create a hidden field to strip off the last 4 characters?

Thank You
User 187934 Photo


Senior Advisor
20,271 posts
Online Now

Yes you can do this.
Add a text field to your form
Name it badnumber
Now add a hidden input to form and name it goodnumber and give it a value of 0
Now add a html element and paste the code below to it.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$('input[name=badnumber]').change(function() {
var numberconvert = $('input[name=badnumber]').val().split("-").pop();
$('input[name=goodnumber]').val(numberconvert);
});
});</script>

Here's an example of how it works. I have a hidden input and a visible input being populated.
http://ericrohloff.com/coffeecup/ccforu … it-number/
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 1882563 Photo


Registered User
9 posts

In my case, I always want to strip and use only first 10 characters.
User 187934 Photo


Senior Advisor
20,271 posts
Online Now

This then.
http://ericrohloff.com/coffeecup/ccforu … front.html

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$('input[name=badnumber]').change(function() {
var numberconvert = $('input[name=badnumber]').val().split("-",1).pop();
$('input[name=goodnumber]').val(numberconvert);
});
});</script>


I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 1882563 Photo


Registered User
9 posts

Seems logical, I created the hidden field added your code but only get the value of 0

My subject line in email is <CASE:[goodnumber]>

Any thoughts
User 187934 Photo


Senior Advisor
20,271 posts
Online Now

Can you share a link to your form?
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 187934 Photo


Senior Advisor
20,271 posts
Online Now

I would double check your html element because there's no JQuery code on that form.:)
Also rename your form without spaces. Spaces can cause problems.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 1882563 Photo


Registered User
9 posts

Eric, thank you. I added the html element and everything works great. Thanks again!

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.