Home
TeamSite
Do not save forms with "&" : using perl regex
parser
Hi friends,
I am very new to TeamSite and perl.
I dont want to save forms which contains ampersand (&) character. I can use perl regular expression in validation regex attribute for each element on that form. Please help me on how to write that. I tried a lot for this but no success.
Help needed.
Regards,
Parser
Find more posts tagged with
Comments
Sailesh
could you be more specific as where do not want "&" to be in your form?? Are you talking about value entered by user while filling data into form?? if that is the case then you can use formAPI to validate..
parser
Hi sailesh,
Thanx for your prompt reply.
Yes, I am talking about value entered by the user. My form contains multiple Text box and Text Area instances. The Text and TextArea instance has an attribute called validation-regex using which you can validate the data entered by the user. You can use perl5 regular expressions for that.
For e.g. Email address : "\w+
@\w+\
.\w+"
If i am entering any other value than the above specified, that area will get highlighted as red while saving the form and the form wont get saved.
I tried a lot to write that regular expression, but i got no success.
Regards,
Parser
Sailesh
instead of using validation regex, you can use your own custom function using javascript and on from Save call that function, there you can trap the value entered by user and set focus.
Need to check formAPI document and will understand what I am talking about.
Let me know if this helps.
jbonifaci
If all you want to do is allow them to enter any character but an &, just use:
"^[^&]*$"
Adam Stoller
"^[^&]*$"
I don't think you want the anchors there - I think you'd just want:
"[^&]"
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
jbonifaci
Adam, without the anchors, all they need to do is enter one character that is not an & and it will let them save. The anchors are 100% needed. And actually, now that I think about it, you might also need to change the & to & in order for your DCT to even render:
"^[^&]*$"
~Jeff
Birt.bmp
Adam Stoller
Hmm - good point - I misread the '*' after the character class and thought that you were only checking the first character typed.
However - it's probably still easier/better to do it with FormAPI:
function no_bad_chars(item){
if (item.getValue().match(/&/)){
return false;
}
return true;
}
(or something like that - you might need to put a back-slash before the '&'?)
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
parser
Thanx jbonifaci,
It worked.
Thanx for all the replies i received for this post from all of you.
Regards,
Parser