I'd like to know if the following php validation is properly coded. It works, but I'd like to know if there's a better way to do it.
if(isset($_POST['account_type']) && $_POST['account_type']==2){
if ((strlen(utf8_decode($this->request->post['cnpj'])) < 3) || (strlen(utf8_decode($this->request->post['cnpj'])) > 32)) {
$this->error['cnpj'] = $this->language->get('error_cnpj');
}
}
I need it like this because I have a hidden required field that is shown only to the customers who are applying for a corporate account. The field is shown after clicking a radio button. So I only need to validate that field [cnpj] when a customer clicks on the retailer account radio button with a value=2.
Thanks a lot.
Marvin M
$this->request->post['cnpj']? int or string?