Skip to main content

validation

More
14 years 3 months ago #52184 by lwlbar
validation was created by lwlbar
Hi Nicolas,

I made a post under general regarding validation for a custom field - customer code. At the moment it uses the existing basic validation that limits the input to a maximum of 6 digits although these can be either alpha or numerique. I need to accomplish validation that is both min/max 6 and only numerique.

Thank you for your response,

Luke

Please Log in or Create an account to join the conversation.

More
14 years 3 months ago #52269 by nicolas
Replied by nicolas on topic Re: validation
Hi,

There is no option for that.
You will have to edit the view file where your custom field is displayed and add custom javascript code to handle that. What kind of custom field is it ? On which table is it set ?

Please Log in or Create an account to join the conversation.

More
14 years 3 months ago #52306 by lwlbar
Replied by lwlbar on topic Re: validation
Hi

I know there is no option for that. That is why I was proposing it under commercial jobs. I am looking for someone to take this on as a commercial job. I have attached a screenshot of the field settings.

kindly,

Luke

Please Log in or Create an account to join the conversation.

More
14 years 3 months ago #52309 by nicolas
Replied by nicolas on topic Re: validation
You can change the line:
echo $this->fieldsClass->display($oneExtraField,$this->$type->$fieldName,'data',false,' '.$onWhat.'="hikashopToggleFields(this.value,\''.$fieldName.'\',\''.$type.'\',0);"'); ?>

to:

echo $this->fieldsClass->display($oneExtraField,$this->$type->$fieldName,'data',false,' '.$onWhat.'="if(this.id==\'address_codeclient\' && ((!isNaN(parseFloat(this.value)) && isFinite(this.value)) || this.value.length!=6)){ alert(\'this field must be a number of 6 characters\'); this.value='\'\; return false;} hikashopToggleFields(this.value,\''.$fieldName.'\',\''.$type.'\',0);"'); ?>

in the file custom_field of the view user via the menu Display->Views.

Please Log in or Create an account to join the conversation.

More
14 years 3 months ago - 14 years 3 months ago #52450 by lwlbar
Replied by lwlbar on topic Re: validation
Hi Nicholas,

Thanks for your kind help, but unfortunatley I am not getting a result from it; the user can still enter alpha characters and sequences less than 6 numeric characters long.

I changed the line, on all templates, cleared cache, etc, but received

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /homepages/23/d411939325/htdocs/cofiparc/templates/objectifprventionsingle/html/com_hikashop/user/custom_fields.php on line 21

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /homepages/23/d411939325/htdocs/cofiparc/templates/objectifprventionsingle/html/com_hikashop/user/custom_fields.php on line 21


any clues?

kindly

Luke
Last edit: 14 years 3 months ago by lwlbar.

Please Log in or Create an account to join the conversation.

More
14 years 3 months ago #52455 by nicolas
Replied by nicolas on topic Re: validation
Try like that:

echo $this->fieldsClass->display($oneExtraField,$this->$type->$fieldName,'data',false,' '.$onWhat.'="if(this.id==\'address_codeclient\' && ((!isNaN(parseFloat(this.value)) && isFinite(this.value)) || this.value.length!=6)){ alert(\'this field must be a number of 6 characters\'); this.value=\'\'; return false;} hikashopToggleFields(this.value,\''.$fieldName.'\',\''.$type.'\',0);"'); ?>

Please Log in or Create an account to join the conversation.

More
14 years 3 months ago #52457 by lwlbar
Replied by lwlbar on topic Re: validation
Sorry that didn't work either...

i did try changing: (this.id==\'address_codeclient to (this.id==\'codeclient as the column name for the field isn't preceeded by address_ ( or should it be!?)

Please Log in or Create an account to join the conversation.

More
14 years 3 months ago #52509 by lwlbar
Replied by lwlbar on topic Re: validation
Hi Nicholas,

Actually my dumb it did indeed work :blush: however its working for alpha characters not numeric, sorry to keep bothering you.

kindly,

Luke

Please Log in or Create an account to join the conversation.

More
14 years 3 months ago #52559 by nicolas
Replied by nicolas on topic Re: validation
Try like that:

echo $this->fieldsClass->display($oneExtraField,$this->$type->$fieldName,'data',false,' '.$onWhat.'="if(this.id==\'address_codeclient\' && (!(!isNaN(parseFloat(this.value)) && isFinite(this.value)) || this.value.length!=6)){ alert(\'this field must be a number of 6 characters\'); this.value=\'\'; return false;} hikashopToggleFields(this.value,\''.$fieldName.'\',\''.$type.'\',0);"'); ?>

Please Log in or Create an account to join the conversation.

More
14 years 3 months ago #52605 by lwlbar
Replied by lwlbar on topic Re: validation
Hi Nicolas


I have added in the most recent code, into the relevent template:

views-->custom_fields-->user-->(template)

without response :(

To be sure it was in the right place, I adjusted each of available templates....(I know this shouldn't be neccessary)

Still no response. :dry:

So I tried to revert to the second attempt ( which accepted only 6 alpha characters) by removing the customizations (under views) then redoing the process.

This attempt had no result either, which I am a bit lost with. :ohmy: I have cleared cache/browser history/etc, the site is online and no one is logged into to either front/back end.

This seems a bit strange. I don't think its fair to say that the latest line isn't correct, but it doesn't appear to be being taken into effect.

kindly,

Luke

Please Log in or Create an account to join the conversation.

More
14 years 3 months ago #52681 by nicolas
Replied by nicolas on topic Re: validation
Can you give a link to that page so that we can see that ?

Please Log in or Create an account to join the conversation.

More
14 years 3 months ago #52683 by lwlbar
Replied by lwlbar on topic Re: validation
cofiparc.objectifprevention.com

let me know where i can send admin access if required

Luke

Please Log in or Create an account to join the conversation.

More
14 years 3 months ago #52781 by nicolas
Replied by nicolas on topic Re: validation
Try like that:

echo $this->fieldsClass->display($oneExtraField,$this->$type->$fieldName,'data',false,' '.$onWhat.'="if(this.id==\'codeclient\' && (!(!isNaN(parseFloat(this.value)) && isFinite(this.value)) || this.value.length!=6)){ alert(\'this field must be a number of 6 characters\'); this.value=\'\'; return false;} hikashopToggleFields(this.value,\''.$fieldName.'\',\''.$type.'\',0);"'); ?>


From the tests I could do on your website, that one is working.

Please Log in or Create an account to join the conversation.

More
14 years 3 months ago #52789 by lwlbar
Replied by lwlbar on topic Re: validation
Nicolas,

thank you ever so much for your time and patience! :laugh:

works like a charm!

bravo,

Luke

Please Log in or Create an account to join the conversation.

Time to create page: 0.324 seconds
Powered by Kunena Forum