[ic] Validating fields in the form

Ed LaFrance interchange-users@interchange.redhat.com
Tue Jan 29 13:04:01 2002


At 04:42 PM 01/29/2002 +1030, you wrote:
>Hi guys;
>
>I am trying to validate some form fields before I save them to DB.
>
>I have someting like this:
>
>[set mv_data_enable]1[/set]
><FORM ACTION .......>
><INPUT TYPE=hidden NAME="mv_form_profile" VALUE="evaluation_profile">
>"all form details here"
>
>then I have:
>
>[if type=explicit compare="[error all=1 show_var=1 keep=1]"]
><font color=__CONTRAST__>There were errors in your last
>submission.</FONT><br>
><ul>
><li>[error all=1 show_var=1 show_error=1 keep=1 joiner="<br><li>"]
></ul>
>The areas that need correction are shown in <FONT
>COLOR=__CONTRAST__>this color</FONT> below.</FONT>
>[/if]
>
>
>....................
>
>Form details in here :
>
>for example  for email address:
>
><TR> <TD>
>[error name=email std_label="Email Address" required=1]</TD>
><TD><INPUT TYPE="TEXT" NAME="email" SIZE="52" MAXLENGTH="50"
>VALUE="[value email]"></TD></TR>
>
>also in profiles.order  I added following:
>
>__NAME__      evaluation_profile
>
>email=required
>email=email
>&setcheck=mv_email [value email]
>__END__
>
>Above works fine.
>
>But what I really want is some more checking.
>
>For example I want to make shore that address is not PO Box
>
>I tried adding following into profiles.order:
>
>[if value address1 =~ /p\.o\.\s*box\b/i]
>No PO boxes allowed for address.
>[/if]
>address1=required
>
>But it seems that is not working.
>
>What I am doing wrong here.

The problem is that address1=required is still satisfied, because they have 
provided a value... just not the one you want.  An order check called 
'regex' was recently added to IC (take look at the WHATSNEW link at the 
developer site), so you could do something like:

variable=regex "^(?![Pp].*[Oo].*[Bb])" "No P.O. Boxes, please"


- Ed L.



>I want to set up this so that when someone types in PO Box address that
>"No  PO boxes allowed for address" message is displayed on screen.
>
>Thanks a lot guys.
>
>Alma
>
>_______________________________________________
>interchange-users mailing list
>interchange-users@interchange.redhat.com
>http://interchange.redhat.com/mailman/listinfo/interchange-users

===============================================================
New Media E.M.S.               Software Solutions for Business
463 Main St., Suite D          eCommerce | Consulting | Hosting
Placerville, CA  95667         edl@newmediaems.com
(530) 622-9421                 http://www.newmediaems.com
(866) 519-4680 Toll-Free       (530) 622-9426 Fax
===============================================================