Forums

Problem with Validation

Larion476 08 Jul, 2011
I am using CF 4.0.RC 1.9 on Joomla 1.5.23
I have installed the Mootools upgrade.

I created a form with about 12 fields, most are text input fields but I have an email, a phone, a date, a time (both with the date picker), a textarea, a hidden field and a CAPCHA.

All the fields are required.

When I was building the form and had 2 fields validation was working fine. Now it is erratic, the pictures below are actual screen-grabs of what is happening. I get the error box stuck on the left side of the screen even when all the fields are filled correctly. Sometimes with the message, sometimes not!

My setting for JS Validation are
:
Enable JS Validation YES
Validation Error Field Titles
JS Validation Theme Blue
JS Validation Language English
Error Event onSubmit

My General settings are:
Load Chronoforms Files Yes
Tight Layout ( By the way I notice that both the frontforms.css and frontforms-tight.css are identical)
Enable Joomla Plugins Yes
Show Top Errors Yes

I tried the form with different templates, the problem is the same

[attachment=2]Chef Open Table_1310158841853.jpeg[/attachment]
[attachment=0]Create an event_1310159250171.jpeg[/attachment]
[attachment=1]Chef Open Table_1310158964840.jpeg[/attachment]

I would appreciate any help
GreyHead 09 Jul, 2011
Hi Larion476,

Please post a link to the form so I can take a quick look.

Bob
GreyHead 09 Jul, 2011
Hi Nabil,

I can see the problem with the date-picker message. This is a known bug - but so far I've failed to re-create it :-(

Please take a Form Backup using the icon in the Forms Manager and post it here (as a zipped file) or PM or email it to me and I'll take a closer look.

Bob
Larion476 09 Jul, 2011
Hi Bob,

Thanks for looking into that. I sent you a PM with the zip file. But it is sitting in my outbox, I don't know if I am doing something wrong. Anyway here is the file again. I created a small form without the datepicker and it seems to work.

Nabil
GreyHead 09 Jul, 2011
Hi Nabil,

I got it thank you.

PMs stay in your Outbox until they are read - then they go to the Sent folder.

Bob
Larion476 09 Jul, 2011
Kept testing,

Added another form to the site called Small Form where I put a date time field with the picker selecting both Date and time in the same field. It seems to work. I'll have fo figure out how to map this to the MyQL table.

Now despite the fact I tell it to display and send Y-m-d H:i, it displays d-m-Y H:i:s.
The info sent to the email is: Y-m-d H:i:s.

Another thing about validation: Phone validation does not seem to work (Except for required). I am in North America so I tried Phone and International Phone, but even if I type 2 digits it takes it. I would like it to check for 10 digits numbers.

About validation; I am used to add validation in the forms or my sites both, javascript and PHP, is there a way I could add validation in CF.

Regards.

Nabil
GreyHead 12 Jul, 2011
Hi Nabil,

How are you setting the date & time picker formats?

The best way to save date & time info in the database table is to use a DATETIME column.

From the code used the FormCheck phone validations only appear to check for the characters used
phone : /^\+{0,1}[0-9 \(\)\.\-]+$/, // alternate regex : /^[\d\s ().-]+$/,/^((\+\d{1,3}(-| )?\(?\d\)?(-| )?\d{1,5})|(\(?\d{2,6}\)?))(-| )?(\d{3,4})(-| )?(\d{4})(( x| ext)\d{1,5}){0,1}$/
phone_inter : /^\+{0,1}[0-9 \(\)\.\-]+$/,
If you want a more specific North American validation then probably the best thing is to add a custom validation using a Regex (the alternate one here is a good start).

I'm not sure what your last point is? ChronoForms supports custom serverside validation using PHP and you're already using the built-in JavaScript validation.

Bob
Larion476 14 Jul, 2011
I found the REGEX for phone in formcheck-yui.js and I can hack it to put mine in place.

But How would I go about adding a custom js validation of my own ?
GreyHead 17 Jul, 2011
Hi Larion476,

You can add a Customised validation by adding a validation class starting with % in the form input and then defining a corresponding function in the Load JavaScript action> Here's an example from the FormCheck documents. The validation class
validate['required','%customCheck']
the function definition
function customCheck(el){
    if (!el.value.test(/^[A-Z]/)) {
        el.errors.push("Username should begin with an uppercase letter");
        return false;
    } else {
        return true;
    }
}
You can replace the test and error message here with your own values.

Bob
adamricky 29 Jul, 2011
I have a form validate script that execute with xupload pro. the balidate function is inside the xupload pro script. it is a simple javascript alart. i want to make it that when it's validate it will focus on the form field and write a messege in red under the field input.



_________________

Overseas consultants in India
GreyHead 29 Jul, 2011
Hi adamricky,

Is xUpload Pro available as a Joomla! extension?

Bob
majdyk 09 Feb, 2012
Hi can you explain how to use it becouse i have to translate validation to Polish and i have problem. I don't know how to use it custom validation.

Hi Larion476,

You can add a Customised validation by adding a validation class starting with % in the form input and then defining a corresponding function in the Load JavaScript action> Here's an example from the FormCheck documents. The validation class

validate['required','%customCheck']
the function definition
function customCheck(el){
    if (!el.value.test(/^[A-Z]/)) {
        el.errors.push("Username should begin with an uppercase letter");
        return false;
    } else {
        return true;
    }
}
You can replace the test and error message here with your own values.

Bob

GreyHead 09 Feb, 2012
Hi majdyk,

In ChronoForms v4 there is already a Polish translation of the standard validation error messages. Is this what you need?

Bob
majdyk 09 Feb, 2012
The messages are in Polish. It works great.


I mean the validation of Polish characters. Now that is just as Polish character types, for example źżć, it shows an error that this is not a letter.
GreyHead 10 Feb, 2012
Hi majdjk,

Try something like this?
function customCheck(el){
    if (!el.value.test(/^[a-zA-Z0-9ĄĘŚĆŻŹŁÓĆŃąęśćżźłóćń@#_* ]/)) {
        el.errors.push("Proszę używać tylko liter i cyfr");
        return false;
    } else {
        return true;
    }
}

Bob
GreyHead 10 Feb, 2012
Hi majdyk,

I don't see that file being loaded into your page.

Please try adding the script snippet to a Load JS action in the form On Load event.

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