Has anyone made a complete javascript form validation for the customer account creation???
I can just about get away with putting anything into the fields and it goes through!
there needs to be something like: no alpha-keys in the phone and fax numbers and a good email validation script.....
That wouldn't be done with javascript. That would be done on the server side. Similar to the way the minimum character count is checked (you obviously have to enter something in required fields).
It's quite easy to add additional validation checks.
It's quite easy to add additional validation checks.
Last edited by Qphoria on Mon Jan 26, 2009 8:03 pm, edited 1 time in total.
You can do it both ways really.
Javascript validation is only ever advice, as the end user can easily over-ride it.
Instead, we use server-side validation.
Javascript validation is only ever advice, as the end user can easily over-ride it.
Instead, we use server-side validation.
Email validation is already being checked for validity. I suppose we could add the actual dns check, but might be overkill.
For the phone and fax (assuming you are using at least v0.7.9 RC6):
EDIT: catalog/controller/account_create.php
FIND:
AFTER, ADD:
You will need to add an entry for the fax error in the language file, and update the message to be more clear of the possible errors:
EDIT: catalog/language/english/controller/account_create.php
FIND:
REPLACE WITH:
AFTER, ADD:
Then edit the tpl file to add the fax error message
EDIT: catalog/template/default/content/account_create.tpl
FIND:
REPLACE WITH:
For the phone and fax (assuming you are using at least v0.7.9 RC6):
EDIT: catalog/controller/account_create.php
FIND:
Code: Select all
if (!$validate->strlen($request->gethtml('telephone', 'post'),3,32)) {
$this->error['telephone'] = $language->get('error_telephone');
}
Code: Select all
if ([color=red]![/color]preg_match('/^[0-9:-]{[color=red]3[/color]}$/', $request->gethtml('telephone', 'post'))) {
$this->error['telephone'] = $language->get('error_telephone');
}
if ($request->gethtml('fax', 'post') != '') {
if ([color=red]![/color]preg_match('/^[0-9:-]{[color=red]3[/color]}$/', $request->gethtml('fax', 'post'))) {
$this->error['fax'] = $language->get('error_fax');
}
}
EDIT: catalog/language/english/controller/account_create.php
FIND:
Code: Select all
$_['error_telephone'] = '* Telephone must be greater than 3 and less than 32 characters!';
Code: Select all
$_['error_telephone'] = '* Telephone must be greater than 3 and less than 32 characters and contain only numbers, dashes, or decimals!';
Code: Select all
$_['error_fax'] = '* Fax must be greater than 3 and less than 32 characters and contain only numbers, dashes, or decimals!';
EDIT: catalog/template/default/content/account_create.tpl
FIND:
Code: Select all
<tr>
<td><?php echo $entry_fax; ?></td>
<td><input type="text" name="fax" value="<?php echo $fax; ?>"></td>
</tr>
Code: Select all
<tr>
<td><span class="required">*</span> <?php echo $entry_fax; ?></td>
<td><input type="text" name="fax" value="<?php echo $fax; ?>">
<?php if ($error_fax) { ?>
<span class="error"><?php echo $error_fax; ?></span>
<?php } ?></td>
</tr>
Last edited by Qphoria on Tue Jan 27, 2009 12:40 pm, edited 1 time in total.
Ah whoops, I forgot the !.. i updated the code above. (the second code block, the changes are in red)
If you want to make post code required, you can add the follow after that code from the second block above:
You will also have to create an error message in the language file, similar to how the existing telephone one was set up
If you want to make post code required, you can add the follow after that code from the second block above:
Code: Select all
if (!$validate->strlen($request->gethtml('postcode', 'post'),3,32)) {
$this->error['telephone'] = $language->get('error_postcode');
}
Last edited by Qphoria on Tue Jan 27, 2009 12:38 pm, edited 1 time in total.
Who is online
Users browsing this forum: No registered users and 28 guests