Forum
Contact form - error messages not appearing
Hello,
First time working with Perch .. really great cms by the way! Keep up the good work!
I created a contact form but I'm having problems with the error messages .. I can't get them to appear on my page. Any idea why?
I watched this video https://docs.grabaperch.com/video/v/form-error-messages/ which is great but what's in the contact-error.html exactly? How's the CSS? It would be useful to have access to these files if possible ..
Also, I can't seem to have an empty first item in my select type .. although I use allowempty -> true or false doesn't matter .. it doesn't work ..
Thanks a lot for your help!
<perch:form id="form-contact" method="post" app="perch_forms" role="form" class="bootstrap-frm">
<div class="hidden_honeypot">
<perch:input type="text" id="spamkiller" antispam="honeypot" />
</div>
<perch:error for="all" type="general">
<div class="alert error">
<perch:content id="error" type="textarea" label="General error message" editor="ckeditor" html="true" />
</div>
</perch:error>
<div>
<perch:label for="name"><span class="blue_text" title="verplichte veld">Naam en voornaam</span></perch:label><br />
<perch:input type="text" id="name" required="true" label="Naam en voornaam" size="100" maxlength="100" />
<perch:error for="name" type="required"><p class="about-error">Vul hier uw naam en voornaam in alstublieft</p></perch:error>
</div>
<div>
<perch:label for="email"><span class="blue_text" title="verplichte veld">E-mail adres</span></perch:label><br />
<perch:input type="email" id="email" required="true" label="E-mail" placeholder="you@company.com" size="100" maxlength="100" />
<perch:error for="email" type="required"><p class="about-error">Vul hier uw e-mail adres in alstublieft</p></perch:error>
<perch:error for="email" type="format"><p class="about-error">U hebt een onjuiste e-mail adres ingevoerd</p></perch:error>
</div>
<div>
<perch:label for="select"><span class="blue_text">Onderwerp</span></perch:label><br />
<perch:input type="select" id="select" label="Onderwerp" options="Afspraak,Sollicitatie,Gastlezing,Andere" allowempty="false" required="true" />
<perch:error for="select" type="required"><p class="about-error">Maak hier een keuze alstublieft</p></perch:error>
</div>
<div>
<perch:label for="message"><span class="blue_text" title="verplichte veld">Bericht</span></perch:label><br />
<perch:input type="textarea" id="message" required="true" label="Bericht" cols="100" size="100" rows="8"/>
<perch:error for="message" type="required"><p class="about-error">Vul hier uw bericht in alstublieft</p></perch:error>
</div>
<div>
<perch:label for="cv"><span class="blue_text">Bijlage opsturen ENKEL in pdf formaat (maximum grootte 5Mb)</span></perch:label><br />
<perch:input type="file" id="cv" accept="pdf" />
<perch:error for="cv" type="format"><p class="about-error">Enkel pdf formaat wordt toegestaan met een maximum grootte van 5Mb</p></perch:error>
</div>
<div>
<perch:input type="submit" id="submit" value="Verzenden" class="button" />
</div>
<perch:success>
<perch:content id="success" type="textarea" label="Bedankingsbericht" editor="ckeditor" html="true" />
</perch:success>
</perch:form>
What happens when you submit the empty form?
I get an error message .. but the classic one .. like on the demo version of Swift .. just a pop-up ..
Do you mean the HTML5 browser validation error before the form submits?
Yes .. like this: https://html5doctor.com/demos/pseudo-classes/figure1.png
That's to be expected - if your browser validates the form it will be correct by the time Perch gets to see it.
right :D how silly .. so I guess I just have to add this attribute to stop my browser from validating the form?
novalidate="novalidate"
How about the empty first item in my select type .. allowempty (true or false) doesn't seem to work ..
thanks for your help!
Use:
Good idea. Thanks!
Hello again,
another problem on this form .. I can't seem to get the error message to appear when sending the wrong file format as an attachment:
do you see anything wrong? Thanks for your help!
Is
pdf
defined as a group in your filetypes.ini file? It's not by default.Apparently it is .. here is the content of my filetypes.ini
Ok, great. If it's not being detected it may be that your server doesn't have the necessary support for it.
Right, thanks! I tested this on my synology nas server .. it's probably gonna work once published.
Thanks for your help!