err..  he was looking for a way to implement without the use of alert boxes.

  I like the DHTML idea.


Will Ryan wrote:

> Use JavaScript, It's a life saver.  We load nearly all of our validation
> scripts in a header file so you call the validation anytime you need it.  We
> never use CFForm because it writes the Javascripts for you.  If need to call
> any JavaScript on an event with a CFForm element is such as onBlur it won't
> work.
>
> here's an  example we implement our JavaScript.
>
> <SCRIPT LANGUAGE="JavaScript">
> <!--
>         // Checks the E-MAIL field.
>                 function valid(form) {
>                         var field = form.EmailAdd; // email field
>                         var str = field.value; // email string
>                         var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
>                         var reg2 =
> /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
>                         if (!reg1.test(str) && reg2.test(str)) { // if syntax is 
>valid
>                                 return true;
>                         }
>                         alert("\"" + str + "\" is an invalid e-mail!"); // alerts 
>that e-mail is
> invalid
>                         field.focus(); //resets focus to e-mail form element
>                         field.select(); //select all characters in that field
>                         return false;
>                 }
>
> //-->
> </SCRIPT>
>
> Now inside your form you element would look like this;
>         <input type="text" name="EmailAdd" size="20" maxlength="50" onBlur="return
> valid(BuilderInfo)" class="mandatory">
>
> Where "BuilderInfo" would be your form name
>
> Hope this helps.
>  Will
>
> -----Original Message-----
> From: Chris Alvarado [mailto:[EMAIL PROTECTED]]
> Sent: Monday, February 12, 2001 12:57 PM
> To: CF-Talk
> Subject: RE: Form validation without alert boxes
>
> as far as the server side goes here is what I do.
>
> <!--- param the variable Error --->
> <cfparam name="Error" default="">
>
> <!--- check to see if the First Name is blank --->
> <cfif Trim(FirstName) Is "">
>         <cfset FNameNullError = "Please enter a First Name">
>         <cfset Error = "True">
> </cfif>
>
> <cfif Error Is "True">
>         <cfinclude template="UserInfoPage.cfm">
> <cfelse>
>         Process all of the stuff
> </cfif>
>
> THEN
>
> on the page that submitted the form.
>
> <cfif IsDefined("FNameNullError")>
>         <font face="verdana" size="1"
> color="red"><cfoutput>#FNameNullError#</cfoutput></font>
> </cfif>
>
> Let me know if you have any questions.
>
> -chris.alvarado
> [developer] - VerticalNet
>
> -----Original Message-----
> From: James Birchler [mailto:[EMAIL PROTECTED]]
> Sent: Monday, February 12, 2001 11:45 AM
> To: CF-Talk
> Subject: Form validation without alert boxes
>
> 1. Client side: Could someone please show me an example of doing client-side
> form validation that doesn't use the alertbox method? It would be nice if
> next to the input field the user would simply see red text explaining their
> input error.
>
> 2. Server side: How about server-side validation using CFFORM with the same
> kind of output--is there an easy way to re-display the original form fields
> with error messages where applicable and keeping/displaying the form entries
> the user has properly entered?
>
> I just need a solid starting point for these problems.
>
> Many thanks,
>
> James
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to