[rt-users] Mandatory Custom Field

Stephen Turner sturner at MIT.EDU
Tue Mar 11 09:19:37 EDT 2008


At Monday 3/10/2008 05:10 PM, Kenneth Crocker wrote:
>Stephen,
>
>
>         Why does yours have so much code? I just tried adding the 
> '?' at the end, in front of the '$' and it still doesn't work. 
> Where would I make a change to yours in order to get 4 positions for year?
>
>Kenn
>LBNL

Kenn,

Our version does more checking on entered values that yours- the one 
you posted would allow something like  66/43/76 as a valid date. 
Looking at ours a bit more closely, it may actually allow a 4-digit 
year, although it also allows a 2-digit year. The year specification 
is the last part - ([12][0-9])?[0-9][0-9] - I'm not a regexpert, but 
I'd guess that removing the ? from the middle of that piece would 
enforce a 4-digit year. The parentheses in that part are also 
probably not needed if you remove the ?.

If you want to extend your version to make it optional, try using parentheses:

(?#Date)^(\d{2}/\d{2}/\d{4})?$

Steve


>On 3/10/2008 11:06 AM, Stephen Turner wrote:
>>At Monday 3/10/2008 12:31 PM, Kenneth Crocker wrote:
>>>To all,
>>>
>>>
>>>         We have a Custom Field called "Need-By Date". It is 
>>> applied to only a
>>>few Queues. In order to ensure the format entered is consistent, I put
>>>the following "(?#Date)^\d{2}/\d{2}/\d{4}$" into the Validation field.
>>>The result is RT demands an entry as though it is a Mandatory Field. I
>>>only wanted the format to be mandatory so that IF it was entered, it
>>>would require the desired format. Any ideas on how to accomplish this?
>>>Thanks ahead of time.
>>>
>>>Kenn
>>>LBNL
>>Kenn,
>>Here's what we have for an optional date field (MM/DD/YY format):
>>'(?#Date-Optional 
>>MM/DD/YY)^(((0)?[1-9]|1[0-2])\/((0)?[1-9]|[12][0-9]|3[01])\/([12][0-9])?[0-9][0-9])?$', 
>>
>>It's the final '?' that makes this optional - without it, the field 
>>is mandatory.
>>Steve
>>
>>Stephen Turner
>>Senior Programmer/Analyst - SAIS
>>MIT Information Services and Technology (IS&T)
>>
>

Stephen Turner
Senior Programmer/Analyst - SAIS
MIT Information Services and Technology (IS&T)





More information about the rt-users mailing list