Author Topic: Required fields not working  (Read 1043 times)

0 Members and 1 Guest are viewing this topic.

Offline Knarbel13

  • Newbie
  • *
  • Posts: 2
Required fields not working
« on: December 22, 2014, 06:08:48 AM »
I'm using form2email on several webistes but only until now discovered that the check for required fields isn't working for me - if the user clicks on the send button without having entered anything he still get's the to the "thank you" page without any notification of errors. What am I doing wrong?

This is how the form on my page looks like:
<form method="get" action="http://domainname.de/cgi-bin/kontakt.pl">
<input type="hidden" name="required_fields" value="name,email,nachricht">
<input name="name" class="formularkasten" value="Ihr Name" onBlur="if(this.value=='') this.value='Ihr Name';" onFocus="if(this.value=='Ihr Name') this.value='';"/><br/><p style="margin-top: 10px;"></p>
<input name="email" class="formularkasten" value="Ihre E-Mail-Adresse" onBlur="if(this.value=='') this.value='Ihre E-Mail-Adresse';" onFocus="if(this.value=='Ihre E-Mail-Adresse') this.value='';"/><br/><p style="margin-top: 10px;"></p>
<input name="Telefon" class="formularkasten" value="Ihre Telefonnummer" onBlur="if(this.value=='') this.value='Ihre Telefonnummer';" onFocus="if(this.value=='Ihre Telefonnummer') this.value='';"/><br/><p style="margin-top: 10px;"></p>                               
<textarea name="nachricht" rows="8" class="formularkasten" />Ihre Nachricht</textarea><br/><p style="margin-top: 10px;"></p>
<div><input type="submit" value="Absenden" name="Absenden" /></div>

And the setting in the script:
my $required_fields_form     = 1;
my @required_fields          = (email,name,nachricht);
my @required_fields_numbers  = ();
my @required_fields_email    = (email);
my $error_fields_require     = "Das Feld ist leer, bitte geben Sie etwas ein";
my $error_fields_numbers     = "Nur Ziffern bitte";
my $error_fields_email       = "Die E-Mail-Addresse ist ungueltig";
my $error_title              = "<b>Entschuldigung</b>";
my $fontColor                = "black";

Offline Jason

  • Administrator
  • Hero Member
  • *****
  • Posts: 1018
    • slipdex
Re: Required fields not working
« Reply #1 on: December 22, 2014, 09:39:44 AM »
Hi,

That is not how that function works. First, I'm not sure which version you are using, but Take this line: my $required_fields_form     = 1; and change it to =0.

Next you need to separate the required fields with quotes. Change this line: my @required_fields          = (email,name,nachricht); to: my @required_fields          = ('email','name','nachricht');

Next change the required e-mail field line from this: my @required_fields_email    = (email); to this: my @required_fields_email    = ('email');

Finally, remove the the line from your web form: <input type="hidden" name="required_fields" value="name,email,nachricht"> completely. This is not needed with the setup I just corrected for you plus the structure of that line is not html compliant anyway. Those changes should fix the issue.

Jason
Founder of www.slipdex.com

Offline Knarbel13

  • Newbie
  • *
  • Posts: 2
Re: Required fields not working
« Reply #2 on: January 20, 2015, 02:38:49 PM »
Thank you very much for the fast reply (and sorry that I'm so late in replying...) - I made the changes you suggested and now the form is working. Great, thanks a lot!  :)