Jump to content

Customization Field, modification to accept IMEI; digits only


Recommended Posts

I have set Customization field as Required, Always for all products first field is the same and required IMEI number.
How and where modify prestashop files, to accept only DIgits in this field, also remove signs like: - or space or / and change only for digits.
In some products is required more then 1 field, but always first field required imei number.
filed 2 or 3 can accept any signs.
Any Idea??

 

I have code for IMEI Validation - Luhn Check

<?php
function validate_imei($imei)
{
	if (!preg_match('/^[0-9]{15}$/', $imei)) return false;
	$sum = 0;
	for ($i = 0; $i < 14; $i++)
	{
		$num = $imei[$i];
		if (($i % 2) != 0)
		{
			$num = $imei[$i] * 2;
			if ($num > 9)
			{
				$num = (string) $num;
				$num = $num[0] + $num[1];
			}
		}
		$sum += $num;
	}
	if ((($sum + $imei[14]) % 10) != 0) return false;
	return true;
}
?>
Edited by zabamich (see edit history)
Link to comment
Share on other sites

×
×
  • Create New...