Jump to content

Character file giving me errors.


mackevin

Recommended Posts

Howdi

Im a real newbie to the programming world, I have a few global files which get included into my php documents. One in particular that allows certain characters in certain fields only. my question to everybody if anybody can help.

the site is a recruitment site and when a job seeker updates his CV he isnt allowed for instance to insert c++ the ++ gives an error. I will attach the file if anybody can give some advice I would be eternally grateful.

 

I think that this is the file that is giving the problems, any idea how I could change it

 

<?php

$g_regNames = "^[ a-zA-Z0-9.,:-]*$";

$g_regEmail = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,5}$";

$g_regTextOnly = "^[a-zA-Z., ]+$";

$g_regTel = "^[ +()0-9-]*$";

$g_regDate = "^[0-9]{4,4}[-][0-9]{2,2}[-][0-9]{2,2}$";

$g_regAlpha = "^[ a-zA-Z0-9.,!@`+()%?:-]+$";

$g_regNumOnly = "^[ 0-9]+$";

$g_regLongText = "[<>\"]";

$g_regTextAndNums = "^[a-Z0-9]+$";

?>

 

Link to comment
https://forums.phpfreaks.com/topic/98390-character-file-giving-me-errors/
Share on other sites

it looks like those regular expressions define different rules that are applied to different fields. if you need to include a plus sign (+), you'd probably do it like this:

 

$g_regTextAndNums = "^[a-Z0-9\+]+$";

 

the plus sign is a special character in regular expressions, so I put the backslash in front of it to 'escape' it, to tell regex to treat it like a plus instead of the special character.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.