Re: How to limit text to 10 characters and eliminating special characters? (71 Views)
Reply
Frequent Advisor
djcj
Posts: 51
Registered: ‎04-27-2010
Message 1 of 28 (71 Views)
Accepted Solution

How to limit text to 10 characters and eliminating special characters?

Please advise. I have a table within a change form that I am trying to update. I am trying to update the table, so that it will limit the text to 10 characters per line and eliminating special characters. Please let me know if you can help me in anyway. Thanks!
Please use plain text.
Honored Contributor
Jacob Heubner
Posts: 4,174
Registered: ‎07-21-2008
Message 2 of 28 (71 Views)

Re: How to limit text to 10 characters and eliminating special characters?

limiting the text is easy -
In Form Designer, set the maximum chars property to 10

As far as previnting special characters, there's no built-in function for that.

Which doesn't mean it's impossible... just not built in.

You might be able to do this with a regular expression in the javascript tab...
Please use plain text.
Honored Contributor
Jacob Heubner
Posts: 4,174
Registered: ‎07-21-2008
Message 3 of 28 (71 Views)

Re: How to limit text to 10 characters and eliminating special characters?

Try this:

On the cm3r formatctrl record
try the following (assuming your special field is called my.field)

In the Calculations tab:
Initial: true
Calculation: cleanup($passed)


In the Javasacript tab:
Update: not null(my.field in $file)

Javascript
Pattern = /^([a-zA-Z])+$/

if (!Pattern.test(record.my_field)){
vars.$passed= false
}
else {
vars.$passed=true
}



In the Validations tab:
Update: not null(my.field in $file)
Validation: $passed
Message: Please use less than 10 characters and no spaces or special characters.
Focus: my.field


Give that a shot.
Please use plain text.
Valued Contributor
Malcom Alga
Posts: 283
Registered: ‎05-04-2009
Message 4 of 28 (71 Views)

Re: How to limit text to 10 characters and eliminating special characters?

love it Jacob...
Please use plain text.
Frequent Advisor
djcj
Posts: 51
Registered: ‎04-27-2010
Message 5 of 28 (71 Views)

Re: How to limit text to 10 characters and eliminating special characters?

Jacob, I tried what you told me but I could not get it to eliminate the special characters. Do you have any other suggestions? Please advise.
Please use plain text.
Honored Contributor
Jacob Heubner
Posts: 4,174
Registered: ‎07-21-2008
Message 6 of 28 (71 Views)

Re: How to limit text to 10 characters and eliminating special characters?

Eliminate or validate? Those are two different things... which are you trying to do?
Please use plain text.
Frequent Advisor
djcj
Posts: 51
Registered: ‎04-27-2010
Message 7 of 28 (71 Views)

Re: How to limit text to 10 characters and eliminating special characters?

Either or...I tried what you told me and it did not validate, but if I could validate or eliminate, either would be fine with me...
Please use plain text.
Honored Contributor
Jacob Heubner
Posts: 4,174
Registered: ‎07-21-2008
Message 8 of 28 (71 Views)

Re: How to limit text to 10 characters and eliminating special characters?

Show me a screenshot of what you have set up.

Be clear with what field you're trying to validate against.

When I set this up in my test system, it works. You have your Maximum Character Length on the field set to 10, and you've got the correct conditions on when the javascript runs.

This _does_ work, so show me what you have.
Please use plain text.
Frequent Advisor
djcj
Posts: 51
Registered: ‎04-27-2010
Message 9 of 28 (71 Views)

Re: How to limit text to 10 characters and eliminating special characters?

You were right. I had to change a few things but it worked perfectly! Thanks for the help. Now I have one more question: is there a way to prompt the "Please use less than 10 characters and no spaces or special characters" message when a user tabs to the next line in the table or presses enter? Please advise. Thanks.
Please use plain text.
Frequent Advisor
djcj
Posts: 51
Registered: ‎04-27-2010
Message 10 of 28 (71 Views)

Re: How to limit text to 10 characters and eliminating special characters?

Hey Jacob,

I was testing out the table this morning and when I put in "ADFS" and tried to save my work it gave me the "Please use less than 10 characters and no spaces or special characters" message. I also tried a number of other ways, but it would not allow me to save my work because the message kept coming up. Could you tell me why it is doing this? Thanks
Please use plain text.
Honored Contributor
Jacob Heubner
Posts: 4,174
Registered: ‎07-21-2008
Message 11 of 28 (71 Views)

Re: How to limit text to 10 characters and eliminating special characters?

did you remember to cleanup the $passed variable?
Please use plain text.
Frequent Advisor
djcj
Posts: 51
Registered: ‎04-27-2010
Message 12 of 28 (71 Views)

Re: How to limit text to 10 characters and eliminating special characters?

yes sir I remembered that.
Please use plain text.
Honored Contributor
Jacob Heubner
Posts: 4,174
Registered: ‎07-21-2008
Message 13 of 28 (71 Views)

Re: How to limit text to 10 characters and eliminating special characters?

Use the RAD debugger and test that variable.
Please use plain text.
Frequent Advisor
djcj
Posts: 51
Registered: ‎04-27-2010
Message 14 of 28 (71 Views)

Re: How to limit text to 10 characters and eliminating special characters?

I tested it and it came back "value is null". Also, I put "not null(sap.transports in $file)" in the initial field in the Javascript tab, and now I can save the ticket if I have no values in the table but if I put any values in then the "Please use less than 10 characters and no spaces or special characters" message will appear and not allow me to save.
Please use plain text.
Honored Contributor
Jacob Heubner
Posts: 4,174
Registered: ‎07-21-2008
Message 15 of 28 (71 Views)

Re: How to limit text to 10 characters and eliminating special characters?

... so yesterday it worked for you (and for me) and you didn't change anything... and today, it doesn't work regardless of what value you put in there?
Please use plain text.
Frequent Advisor
djcj
Posts: 51
Registered: ‎04-27-2010
Message 16 of 28 (71 Views)

Re: How to limit text to 10 characters and eliminating special characters?

Well yesterday when I said it worked, I meant that the "Please use less than 10 characters and no spaces or special characters" message was appearing when I attempted to put in special characters and tried to save the ticket. But I never actually tried to save the ticket with normal characters because I assumed it would work.
Please use plain text.
Honored Contributor
Jacob Heubner
Posts: 4,174
Registered: ‎07-21-2008
Message 17 of 28 (71 Views)

Re: How to limit text to 10 characters and eliminating special characters?

show me screenshots, please, of the formactrl calculation, the javascript, and the validation please.

THis works on my test system, so let's see what the difference is.
Please use plain text.
Frequent Advisor
djcj
Posts: 51
Registered: ‎04-27-2010
Message 18 of 28 (71 Views)

Re: How to limit text to 10 characters and eliminating special characters?

I hope I did this right...I am attaching a word doc with all the screen prints because I cannot use my photobucket at work. Please let me know if you get the word doc
Please use plain text.
Frequent Advisor
djcj
Posts: 51
Registered: ‎04-27-2010
Message 19 of 28 (71 Views)

Re: How to limit text to 10 characters and eliminating special characters?

Did the attachment come out ok?
Please use plain text.
Honored Contributor
Jacob Heubner
Posts: 4,174
Registered: ‎07-21-2008
Message 20 of 28 (71 Views)

Re: How to limit text to 10 characters and eliminating special characters?

Well, the .doc didn't come through, but the screenshots did as .tiff files, so I could see them...

But not seeing the problem yet. All I can see is that when my system has the same code, I don't get the error.

I'll share a screenshot:

Please use plain text.
Frequent Advisor
djcj
Posts: 51
Registered: ‎04-27-2010
Message 21 of 28 (71 Views)

Re: How to limit text to 10 characters and eliminating special characters?

Jacob,

I got it to work in the subcategory field, but I cannot get it to work in the SAP Transport table. This field is an array character in the tool and a clob in the database. The data is stored in a table in the form. I have provided screen shots of the form that I am talking about with valid and invalid values.
Please use plain text.
Honored Contributor
Jacob Heubner
Posts: 4,174
Registered: ‎07-21-2008
Message 22 of 28 (71 Views)

Re: How to limit text to 10 characters and eliminating special characters?

For an array field you need to change the javascript slightly.

you need to set up a for... loop with a break statement.

Pattern = /^([a-zA-Z])+$/

for (i=0;i
if (!Pattern.test(record.reviewer_class[i])){
vars.$passed= false
break
}
else {
vars.$passed=true
}
}

Please use plain text.
Frequent Advisor
djcj
Posts: 51
Registered: ‎04-27-2010
Message 23 of 28 (71 Views)

Re: How to limit text to 10 characters and eliminating special characters?

Jacob,

Thank you for your help, I really appreciate everything. I tried javascript and it is saving both the valid and invalid values. Is there anything else that I can do for it? Did this work on your system?
Please use plain text.
Frequent Advisor
djcj
Posts: 51
Registered: ‎04-27-2010
Message 24 of 28 (71 Views)

Re: How to limit text to 10 characters and eliminating special characters?

//Pattern= A-Z or a-z Alphabets and number 0-9 only allowed
Ok, so I tried this (see below), my co-worker changed the "reviewer_class" to "sap_transport" and I was able to save the ticket when I put in valid values and I received the message when I put in invalid values. So thank you again for your help! Also, I am going to put some points on another comment as I did not give you enough points for all your help!


Pattern = /^([a-zA-Z0-9])+$/

for (i=0;i
if (!Pattern.test(record.sap_transports[i])){
vars.$passed=false
break
}
else {
vars.$passed=true
}
}
Please use plain text.
Frequent Advisor
djcj
Posts: 51
Registered: ‎04-27-2010
Message 25 of 28 (71 Views)

Re: How to limit text to 10 characters and eliminating special characters?

So I am back with another question:

Is there a way to prompt the "Please use less than 10 characters and no spaces or special characters" message when a user tabs to the next line in the table or presses enter to go to the next line? Please advise. Thanks.
Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation