- Posts: 84
- Thank you received: 0
validation
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.
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.
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.
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.
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
Please Log in or Create an account to join the conversation.
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.
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.
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.
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.
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.
Please Log in or Create an account to join the conversation.
let me know where i can send admin access if required
Luke
Please Log in or Create an account to join the conversation.
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.
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.