Hi, This is my first time ever posting to a forum. I am just starting with Coldfusion. I created a form that would validate the form field upon submission. Everything worked until I tried to enter an email address to my form.
If I left all fields blank, the Required error would show. If I inputted any thing into the Username or Password fields, it would check against the regular expression. If I leave the email field blank, the Required error would show. But if I enter anything into the email field that is when I get the error "Element E is undefined in FORM." I am thinking it has something to do that error part of the array is blank. But it is blank to begin with then it is populated and the form is first displayed. Below is the code for the page. Please any help would be greatly appreciated. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>RSO Membership Sign-up</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link href="../style/default2.css" rel="stylesheet" type="text/css"> <style type="text/css"> <!-- @import url("../style/form.css"); --> </style> </head> <body> <!--- <cfcache action="cache" timespan="#createTimeSpan(0, 5, 0, 0)#"> ---> <!--- Set Form Variables to Validate ---> <cfparam name="FORM.m_username" default=""> <cfparam name="FORM.m_password" default=""> <cfparam name="FORM.m_password_verify" default=""> <cfparam name="FORM.m_email" default=""> <cfparam name="FORM.submit" default=""> <!--- Database Variables ---> <cfset query = "get_fields"> <cfset dsn = "rsodb"> <cfset table = "m_list_form"> <cfset orderby = "a_list_order"> <!--- Query ---> <cfquery name="#query#" datasource="#dsn#"> SELECT * FROM #table# ORDER BY #orderby# ASC; </cfquery> <!--- Array ---> <cfset forminput = arraynew(2)> <cfloop query="#query#"> <cfset forminput[currentRow][1] = a_list_order> <cfset forminput[currentRow][2] = b_list_fieldname> <cfset forminput[currentRow][3] = c_list_label> <cfset forminput[currentRow][4] = d_list_defaultvalue> <cfset forminput[currentRow][5] = e_list_errors> <cfset forminput[currentRow][6] = f_list_inputtype> </cfloop> <!--- Append Form Errors ---> <cfif FORM.submit EQ "Submit"> <cfif Len(trim(FORM.m_username)) EQ 0> <cfset forminput[1][5] = "REQUIRED."> <cfelse> <cfset ckUsername = REFindNoCase("^[a-zA-Z]([_a-zA-Z0-9-]+)", trim(FORM.m_username), 1, "True")> <cfif ckUsername.len[1] LT len(trim(FORM.m_username))> <cfset forminput[1][5] = "USE ONLY LETTERS, NUMBERS, HYPENS, OR UNDERSCORES."> <cfelse> <cfset forminput[1][4] = FORM.m_username> </cfif> </cfif> <cfif Len(trim(FORM.m_password)) EQ 0> <cfset forminput[2][5] = "REQUIRED."> <cfelse> <cfset ckPassword = REFindNoCase("^[a-zA-Z0-9]([a-zA-Z0-9]+)", trim(FORM.m_password), 1, "True")> <cfif ckPassword.len[1] LT len(trim(FORM.m_password))> <cfset forminput[2][5] = "USE ONLY LETTER AND NUMBERS."> <cfelse> <cfset forminput[2][4] = FORM.m_password> </cfif> </cfif> <cfif Len(trim(FORM.m_password_verify)) EQ 0> <cfset forminput[3][5] = "REQUIRED."> <cfelse> <cfset ckPasswordVerify = REFindNoCase("^[a-zA-Z0-9]([a-zA-Z0-9]+)", trim(FORM.m_password_verify), 1, "True")> <cfif ckPasswordVerify.len[1] LT len(trim(FORM.m_password_verify))> <cfset forminput[3][5] = "USE ONLY LETTER AND NUMBERS."> <cfelse> <cfset forminput[3][4] = FORM.m_password_verify> </cfif> </cfif> <cfif Len(trim(FORM.m_email)) EQ 0> <cfset forminput[4][5] = "REQUIRED."> <cfelse> <cfset ckEmail = REFindNocase("^[_a-z0-9-]+(\.[_a-z0-9-]+)[EMAIL PROTECTED](\.[a-z0-9-]+)*\.(([a-z]{2,3})|(aero|coop|info|museum|name))$", trim(FORM.m_email), 1, "True")> <cfif ckEmail.len[1] LT len(trim(FORM.e-mail))> <cfset forminput[4][5] = "NOT A VALID EMAIL ADDRESS."> <cfelse> <cfset forminput[4][4] = FORM.m_email> </cfif> </cfif> </cfif> <cfset num_inputs = arraylen(forminput)> <!--- Form Output ---> <form name="m_signup" id="m_signup" action="m_signup.cfm" method="post"> <cfloop index="row" from="1" to="#num_inputs#"> <cfoutput> <label for="#forminput[row][2]#">#forminput[row][3]#</label> <input id="#forminput[row][2]#" name="#forminput[row][2]#" value="#forminput[row][4]#" type="#forminput[row][6]#"><br> <label for="empty"></label> <span class="error">#forminput[row][5]#</span><br> </cfoutput> </cfloop> <cfinclude template="mtype_list.cfm"> <label for="submit"> </label> <button type="submit" id="submit" name="submit" value="submit">Submit</button><br> </form> </body> </html> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Download the latest ColdFusion 8 utilities including Report Builder, plug-ins for Eclipse and Dreamweaver updates. http;//www.adobe.com/cfusion/entitlement/index.cfm?e=labs%5adobecf8%5Fbeta Archive: http://www.houseoffusion.com/groups/CF-Newbie/message.cfm/messageid:2991 Subscription: http://www.houseoffusion.com/groups/CF-Newbie/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15
