Re: [WebDNA] Require no empty field
This WebDNA talk-list message is from 2010
It keeps the original formatting.
numero = 105848
interpreted = N
texte = --Apple-Mail-1-396253132Content-Type: text/plain;charset=US-ASCII;format=flowed;delsp=yesContent-Transfer-Encoding: 7bitSure Li, lots of people here can help, and several of them would be glad to help. Like me.Lawrence also just posted an answer to you, but (without actually reading the link/suggestion he gave you), I assume that uses javascript and one should never rely on javascript alone for form validation. Some people (and machines) do not use javascript. Whatever you do or do not do for form validation on the client side (like with javascript) you also need to back up with server side code (like webdna).Can you post a simplified version of your form, and the file you post to, so we can see the source code that needs to be worked with?I like to use a reusable webdna library for form validation so I do not have to rewrite my validation routine every time I need it for a new form. I am happy to share my validation library code with you, but if you are starting from scratch (i.e. this is your first time), then maybe you would learn best by just seeing how it might be done, very simply, just for your current need."Psuedo code" is when we describe in plain language what we want our code to do. So in psuedo code, what you need might go something like this:1) form page ("form") posts to itself, which makes it be in 'receiver- page-mode' ("reciever")2) "receiver" checks to see if any of the required fields are "blank" (equal to a string of characters which is zero characters in length)- if any of those required fields are blank, then display the "form" with the data already input, but also now a message to user to complete everything as required.- if none of the required fields are blank, then user correctly filled out the form, and so take action (send email to admin person).That, in real code, might look something like this:--------------------------------------------------------------------------------------------------------------------------------------------[text show=F]alertUserHisMistake=[/text][if ("[URL][formWasSubmitted][/URL]"="T")][then][!]---this is 'receiver-page-mode'---[/!][text show=F]usersNameIsRequired=[RemoveHTML][usersNameIsRequired][/ RemoveHTML][/text][text show=F]emalIsRequired=[RemoveHTML][emalIsRequired][/RemoveHTML] [/text][text show=F]thisFieldNOTrequired=[RemoveHTML][thisFieldNOTrequired] [/RemoveHTML][/text][showif [URL][usersNameIsRequired][/URL]=][text show=F]alertUserHisMistake=[alertUserHisMistake]the 'usersNameIsRequired' field is required.
[/text][/showif][showif [URL][emalIsRequired][/URL]=][text show=F]alertUserHisMistake=[alertUserHisMistake]the 'emalIsRequired' field is required.
[/text][/showif][!]---if no user errors, then send the email---[/!][showif [URL][alertUserHisMistake][/URL]=][!]---[alertUserHisMistake] is still blank, so user committed no errors; so now send email.---[/!][sendmail to=[yourAdminAddress]&from=[URL][emalIsRequired][/ URL]&subject=someSubject]the user said this:usersNameIsRequired=[usersNameIsRequired]emalIsRequired=[emalIsRequired]thisFieldNOTrequired=[thisFieldNOTrequired][/sendmail][/showif][/then][else][!]---user has not yet submitted the form, initialize the form fields to blank.---[/!][text show=F]usersNameIsRequired=[/text][text show=F]emalIsRequired=[/text][text show=F]thisFieldNOTrequired=[/text][/else][/if]
Untitled[showif [URL][alertUserHisMistake][/URL]!]
[alertUserHisMistake]
[/showif]
--------------------------------------------------------------------------------------------------------------------------------------------put that on your server and play with it to get a feeling how it works. The next step will be to validate the email address so it must look like a real email address. Like what if the user enters something but it is not a valid address?-GovindaOn Sep 29, 2010, at 4:07 PM, Li Yang wrote:>> Is anybody can help me out with a code that require no empty field > in my form?> I have a form that I want to make customer filled with their > information. there are two fields that I wish they will not leave > them as empty field because we need to collecting their email > address and name to contact them back.>> thanks for your help!--Apple-Mail-1-396253132Content-Type: text/html;charset=US-ASCIIContent-Transfer-Encoding: quoted-printableSure Li, lots of people here =can help, and several of them would be glad to help. Like =me.
Lawrence also just posted an answer to you, but =(without actually reading the link/suggestion he gave you), I assume =that uses javascript and one should never rely on javascript alone for =form validation. Some people (and machines) do not use javascript. = Whatever you do or do not do for form validation on the client =side (like with javascript) you also need to back up with server side =code (like webdna).
Can you post a simplified =version of your form, and the file you post to, so we can see the source =code that needs to be worked with?
I like to =use a reusable webdna library for form validation so I do not have to =rewrite my validation routine every time I need it for a new form. I am =happy to share my validation library code with you, but if you =are starting from scratch (i.e. this is your first time), then maybe you =would learn best by just seeing how it might be done, very simply, just =for your current need.
"Psuedo code" is when we =describe in plain language what we want our code to do. So in =psuedo code, what you need might go something like =this:
1) form page ("form") posts to itself, =which makes it be in 'receiver-page-mode' ("reciever")
2) ="receiver" checks to see if any of the required fields are "blank" =(equal to a string of characters which is zero characters in =length)
- if any of those required fields =are blank, then display the "form" with the data already input, but also =now a message to user to complete everything as =required.
- if none of the required fields =are blank, then user correctly filled out the form, and so take action =(send email to admin person).
That, in real =code, might look something like =this:
-------------------------------------------=--------------------------------------------------------------------------=-----------------------
<!DOCTYPE HTML PUBLIC ="-//W3C//DTD HTML 4.01 Transitional//EN"
<html =lang=3D"en">
[text =show=3DF]alertUserHisMistake=3D[/text]
[if =("[URL][formWasSubmitted][/URL]"=3D"T")]
=[then]
[!]---this is ='receiver-page-mode'---[/!]
[text =show=3DF]usersNameIsRequired=3D[RemoveHTML][usersNameIsRequired][/RemoveHT=ML][/text]
[text =show=3DF]emalIsRequired=3D[RemoveHTML][emalIsRequired][/RemoveHTML][/text]=
=[text =show=3DF]thisFieldNOTrequired=3D[RemoveHTML][thisFieldNOTrequired][/Remove=HTML][/text]
[showif =[URL][usersNameIsRequired][/URL]=3D]
=[text show=3DF]alertUserHisMistake=3D[alertUserHisMistake]the ='usersNameIsRequired' field is =required.<br>[/text]
[/showif]
=[showif [URL][emalIsRequired][/URL]=3D]
=[text show=3DF]alertUserHisMistake=3D[alertUserHisMistake]the ='emalIsRequired' field is required.<br>[/text]
=[/showif]
[!]---if no user errors, =then send the email---[/!]
[showif =[URL][alertUserHisMistake][/URL]=3D]
=[!]---[alertUserHisMistake] is still blank, so user committed no =errors; so now send email.---[/!]
[sendmail =to=3D[yourAdminAddress]&from=3D[URL][emalIsRequired][/URL]&subject==3DsomeSubject]
the user =said this:
=usersNameIsRequired=3D[usersNameIsRequired]
=emalIsRequired=3D[emalIsRequired]
=thisFieldNOTrequired=3D[thisFieldNOTrequired]
=[/sendmail]
=[/showif]
[/then]
=[else]
[!]---user has not yet =submitted the form, initialize the form fields to =blank.---[/!]
[text =show=3DF]usersNameIsRequired=3D[/text]
=[text show=3DF]emalIsRequired=3D[/text]
=[text show=3DF]thisFieldNOTrequired=3D[/text]
=[/else]
[/if]
<head>
=
=<meta http-equiv=3D"content-type" content=3D"text/html; =charset=3Dutf-8">
=<title>Untitled</title>
</head>
<body>[showif =[URL][alertUserHisMistake][/URL]!]
=<p style=3D"color:red;">
=[alertUserHisMistake]
=</p>
=[/showif]
<form action=3D"[thisurl]" =method=3D"post">
=usersNameIsRequired=3D<input name=3D"usersNameIsRequired" =type=3D"text" =value=3D"[input][usersNameIsRequired][/input]"><br>
=emalIsRequired=3D<input name=3D"emalIsRequired" type=3D"text" =value=3D"[input][emalIsRequired][/input]"><br>
=thisFieldNOTrequired=3D<input name=3D"thisFieldNOTrequired" =type=3D"text" =value=3D"[input][thisFieldNOTrequired][/input]"><br>
=<input name=3D"formWasSubmitted" type=3D"hidden" =value=3D"T">
<input name=3D"go" =type=3D"submit" value=3D"go!">
=</form>
</body>
</html>
=
----------------------------------------------------------=--------------------------------------------------------------------------=--------
put that on your server and play =with it to get a feeling how it works. The next step will be to =validate the email address so it must look like a real email address. = Like what if the user enters something but it is not a valid =address?
On Sep 29, 2010, at 4:07 PM, Li Yang wrote:
Is anybody =can help me out with a code that require no empty field in my =form?
I have a form that I want to make customer filled with =their information. there are two fields that I wish they will not =leave them as empty field because we need to collecting their email =address and name to contact them back.
=
thanks for your help!
=body>=--Apple-Mail-1-396253132--
Associated Messages, from the most recent to the oldest:Lawrence also just posted an answer to you, but =(without actually reading the link/suggestion he gave you), I assume =that uses javascript and one should never rely on javascript alone for =form validation. Some people (and machines) do not use javascript. = Whatever you do or do not do for form validation on the client =side (like with javascript) you also need to back up with server side =code (like webdna).
Can you post a simplified =version of your form, and the file you post to, so we can see the source =code that needs to be worked with?
I like to =use a reusable webdna library for form validation so I do not have to =rewrite my validation routine every time I need it for a new form. I am =happy to share my validation library code with you, but if you =are starting from scratch (i.e. this is your first time), then maybe you =would learn best by just seeing how it might be done, very simply, just =for your current need.
"Psuedo code" is when we =describe in plain language what we want our code to do. So in =psuedo code, what you need might go something like =this:
1) form page ("form") posts to itself, =which makes it be in 'receiver-page-mode' ("reciever")
2) ="receiver" checks to see if any of the required fields are "blank" =(equal to a string of characters which is zero characters in =length)
-------------------------------------------=--------------------------------------------------------------------------=-----------------------
<!DOCTYPE HTML PUBLIC ="-//W3C//DTD HTML 4.01 Transitional//EN"
<html =lang=3D"en">
[text =show=3DF]alertUserHisMistake=3D[/text]
[if =("
[url][formWasSubmitted][/URL]"=3D"T")]
=[then]
[!]---this is ='receiver-page-mode'---[/!]
[text =show=3DF]usersNameIsRequired=3D
[removehtml][usersNameIsRequired][/RemoveHT=ML][/text]
[text =show=3DF]emalIsRequired=3D
[removehtml][emalIsRequired][/RemoveHTML][/text]=
=[text =show=3DF]thisFieldNOTrequired=3D
[removehtml][thisFieldNOTrequired][/Remove=HTML][/text]
[showif =
[url][usersNameIsRequired][/URL]=3D]
=[text show=3DF]alertUserHisMistake=3D[alertUserHisMistake]the ='usersNameIsRequired' field is =required.<br>[/text]
[/showif]
=[showif
[url][emalIsRequired][/URL]=3D]
=[text show=3DF]alertUserHisMistake=3D[alertUserHisMistake]the ='emalIsRequired' field is required.<br>[/text]
=[/showif]
[!]---if no user errors, =then send the email---[/!]
[showif =
[url][alertUserHisMistake][/URL]=3D]
=[!]---[alertUserHisMistake] is still blank, so user committed no =errors; so now send email.---[/!]
[sendmail =to=3D[yourAdminAddress]&from=3D
[url][emalIsRequired][/URL]&subject==3DsomeSubject]
the user =said this:
=usersNameIsRequired=3D[usersNameIsRequired]
=emalIsRequired=3D[emalIsRequired]
=thisFieldNOTrequired=3D[thisFieldNOTrequired]
=[/sendmail]
=[/showif]
[/then]
=[else]
[!]---user has not yet =submitted the form, initialize the form fields to =blank.---[/!]
[text =show=3DF]usersNameIsRequired=3D[/text]
=[text show=3DF]emalIsRequired=3D[/text]
=[text show=3DF]thisFieldNOTrequired=3D[/text]
=[/else]
[/if]
<head>
=
=<meta http-equiv=3D"content-type" content=3D"text/html; =charset=3Dutf-8">
=<title>Untitled</title>
</head>
<body>[showif =
[url][alertUserHisMistake][/URL]!]
=<p style=3D"color:red;">
=[alertUserHisMistake]
=</p>
=[/showif]
=usersNameIsRequired=3D<input name=3D"usersNameIsRequired" =type=3D"text" =value=3D"
[input][usersNameIsRequired][/input]"><br>
=emalIsRequired=3D<input name=3D"emalIsRequired" type=3D"text" =value=3D"[input][emalIsRequired][/input]"><br> =thisFieldNOTrequired=3D<input name=3D"thisFieldNOTrequired" =type=3D"text" =value=3D"
[input][thisFieldNOTrequired][/input]"><br>
=<input name=3D"formWasSubmitted" type=3D"hidden" =value=3D"T">
<input name=3D"go" =type=3D"submit" value=3D"go!">
=</form>
</body>
</html>
=
put that on your server and play =with it to get a feeling how it works. The next step will be to =validate the email address so it must look like a real email address. = Like what if the user enters something but it is not a valid =address?
The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...