Hi guys,

Firstly let me apologise for asking this if it is a stupid question. :-)

I've only recently started trying to use the validateRM in conjunction with cgi:app and I must say I am impressed.
I've not had any experience with the validation frameworks before, so some aspects are very confusing to me.
(as an added problem, I'm not a guru like a good many on this list appear to be.)


Anyway, I have a couple of little questions I'd like to ask you.

Firstly I have a need to check that two password fields on a page match: password and password2. (to ensure they entered it properly), can I use validate to do this or must it be coded separately?
Normally I would match them manually, and return if they don't match with my homegrown messaging system, but if I can do that with validateRM it would make sense to do so.
From the look of it, I could do the match manually and put any error into the $err_page object to return the message, it is that the best way to do it?


One thing thing that I couldn't find in Marks example code is a way to pass custom error messages on a per field basis. right now I am getting basic "invalid" or "missing" errors.

Below is the very basic code I have working thus far. (I've not tweaked the regex beyond anything very basic at this stage.)
I'd like to be able to pass error messages like: (for username) "must be at least 8 characters"
and if the passwords don't match: "Your passwords don't match"
And so on for the other fields.


I thought putting:
err_username => 'Username must be over 6 characters',
Into the "msgs" hash would force that message, but it doesn't appear to be working, I still get the "Invalid" message.


Can anyone give me pointers in this regard?

many thanks

Rgds

Franki

my ($results,$err_page) = $self->check_rm('start_window', {
required => [qw/
username
password
password2
muncipality_name
muncipality_number
muncipality_street
muncipality_city
muncipality_state
muncipality_zip
muncipality_auth_officer
muncipality_phone
/],
optional => [qw/
muncipality_fax
muncipality_email
/],
constraints => {
# required params
username => '/\w{4}/',
password => '/\w{6}/',
password2 => '/\w{6}/',
muncipality_name => '/\w{2}/',
muncipality_number => '/\w{1}/',
muncipality_street => '/\w{3}/',
muncipality_city => '/\w{3}/',
muncipality_state => '/\w{2}/',
muncipality_zip => '/\d{3}/',
muncipality_auth_officer=> '/\w{3}/',
muncipality_phone => '/\d{6}/',
# optional params
muncipality_fax => '/\d{6}/', # make sure the fax is over 6 digits.
muncipality_email => '/\w{5}/', # make sure the email is valid.
}, # trim leading and trailing whitespace from all the valid fields.
filters => ['trim'],
msgs=>{
any_errors => 'err__',
prefix =>'err_',
}, });






---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/[EMAIL PROTECTED]/
             http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to