First, i need some one familiar with xoops,
i did some hack on the edituser.php and function .php to add in the validation on Real Name (only alphabet allow) and telephone (only numbers allow), with the it work code below,
But my problem is i couldn't add the check value length function for postcode. the postcode keyin must be 5 digit, if more or less than 5 digit the error message will show. at bottom i the coding i had try. Hope can get help on here,
code on edituser.php
CODE
$name = '';
if (!empty($_POST['name'])) {
$name = $myts->stripSlashesGPC(trim($_POST['name']));
}
if ($name == '' || !checkname($name)) {
$errors[] = _US_NEEDNAME;
}
$tel_hp = '';
if (!empty($_POST['tel_hp'])) {
$tel_hp = $myts->stripSlashesGPC(trim($_POST['tel_hp']));
}
if ($tel_hp == '' || !checkphone($tel_hp)) {
$errors[] = _US_NEEDHP;
}
code on function.php
CODE
function checkname($name)
{
if (!$name || !preg_match("/^[a-z @]+$/i",$name)){
return false;
}
return $name;
}
function checkphone($tel_hp)
{
if (!$tel_hp || !preg_match("/^[0-9-]+$/i",$tel_hp)){
return false;
}
return $tel_hp;
}
Code i try for check length on function.php
CODE
function checkIC($post)
{
for ($i=0; $i<strlen($post); $i++) {
if ($post.charAt(i) < 5){
return false;
}
}
return $post;
}