Validation different messages

mac 19 Feb, 2009
:) Hello!
In my chronoForm form for contact I want to give different messages back:

1 - required (not blank)
7- validate-email (a valid email address)

Is it possible to give one message if the user let the inputfield blank and another message when the E-Mail is not valid.

In the FormCode | Form HTML
in the title tag is the message. But there can stand only one message.

<td><input maxlength="60" size="40" name="FIRMA" title="Bitte geben Sie Ihren Firmennamen ein." class="standard" />

Thank you for your help.
Mac
GreyHead 19 Feb, 2009
Hi mac,

You can also add extra divs to show error messages
<div id='advice-required-field_id' >This field is required</div>
<div id='advice-email-field_id' >This field is required</div>
Replace field_id with the id of the field you want to validate.

The structure of the id is 'advice-' + 'validation class' + 'field id' so that you could have different messages for different validations on the same field. This div can be placed anywhere in the form html.

Bob
mac 19 Feb, 2009
Hi Bob,
I don't now, how I must team
<tr>
<td>E-Mail*</td>
<td><input maxlength="60" size="40" name="EMAIL" title="Bitte geben Sie Ihre korrekte E-Mail-Adresse ein." class="standard" /></td>
</tr>

with
<div id='advice-required-field_EMAIL' >E-Mail1</div>
<div id='advice-email-EMAIL' >E-Mail2</div>


Both written in the FormHtml.

Mac
GreyHead 19 Feb, 2009
HI Mac,

Try this - you need an id in the input field.
<tr>
<td>E-Mail*</td>
<td><input maxlength="60" size="40" id='email' name="EMAIL" title="Bitte geben Sie Ihre korrekte E-Mail-Adresse ein." class="standard" />
<div id='advice-required-field-email' >E-Mail1</div>
<div id='advice-email-email' >E-Mail2</div></td>
</tr>

Bob
mac 19 Feb, 2009
Hi Bob,
the text
<div id='advice-required-field_id' >This field is required</div>
is directly shown in the form when I am writing this.

Mac
GreyHead 19 Feb, 2009
Hi mac,

I don't understand why that text is in the Form HTML at all? It needs to be like the last example I posted.

Bob
mac 20 Feb, 2009
Hi Bob,
when I paste all this tags and text in the form html
<tr>
<td>E-Mail*</td>
<td><input maxlength="60" size="40" id='email' name="EMAIL" title="Bitte geben Sie Ihre korrekte E-Mail-Adresse ein." class="standard" />
<div id='advice-required-field-email' >E-Mail1</div>
<div id='advice-email-email' >E-Mail2</div></td>
</tr>

than, this is shown

[attachment=0]form.gif[/attachment]

Regards
Mac
mac 20 Feb, 2009
Hi Bob,
😶 I am confused
Is it not right, that I place the code (last post) in the 'form code' 'form html' ?

Mac
GreyHead 20 Feb, 2009
Hi Mac,

That's the right place - does the validation work? I think you may need to remove the class='standard' attribute from the input box to get the validation working correctly.

Bob
mac 20 Feb, 2009
Hi Bob,
I must cut out the title tag, put in the id='email'
than I get the right messages
1. This is a required field.
2. Please enter a valid email address. For example [email]fred@domain.com[/email] .
I want this messages in german.

The div id in the 'form html' writes the words between the tags directly in the form.
<div id='advice-required-field_id' >Dies ist ein Pflichtfeld</div>
<div id='advice-email-field_id' >Bitte geben Sie Ihre vollständige E-Mail Adresse ein.</div>


Mac
GreyHead 20 Feb, 2009
Hi mac,

[sendfb][/sendfb]
Bob
mac 20 Feb, 2009
Hi Bob,
thanks a lot for your help!

Mac
GreyHead 21 Feb, 2009
Hi Mac,

I have this working, I left Validation On in the Validation tab but removed the field names from the boxes and inserted the classes by hand. Note that I had to add the css to hide the message divs.
<tr>
<td>E-Mail*</td>
<td><input maxlength="60" size="40" id='email' name="EMAIL" class="standard validate-email required" />
<div style='display:none;color:red;' id='advice-required-email'>Dies ist ein Pflichtfeld</div>
<div style='display:none;color:red;' id='advice-validate-email-email'>Bitte geben Sie Ihre vollständige E-Mail Adresse ein.</div>
</tr>

Bob

[attachment=0]21-02-2009 10-48-24.png[/attachment]
mac 21 Feb, 2009
:D Thank you Bob
for your clever resolution!

? In my chronoform the germann umlaute (ä, ö, ü) are not correctly displayed.

Mac
GreyHead 21 Feb, 2009
Hi Mac,

Could be a page language setting - try searching here for UTF

Also it's safer if you use html entities - ä ö ü etc.

Bob
mac 21 Feb, 2009
Thank you very much!!! for all help!!!

I had similar problem with Russian letters, I solved it by adding adding the line in htaccess file directive without any hacks mentioned above :
AddDefaultCharset UTF-8


Regards
Mac
colemjosel 28 Nov, 2012
Hi Bob;

How can i move div error-message after label using Errors location -> After element.

Regards
GreyHead 02 Dec, 2012
Hi colemjosel,

There's no really simple way of doing this :-(

You could edit the form code to move the error divs e.g.:
<div id="error-message-input_text_1">
Or you could write JavaScript to add a new error element and use the FormCheck 'target' option to have the message display there.

Bob

Bob
This topic is locked and no more replies can be posted.