Delphi For PHP Forums    


Go Back   Delphi-PHP Forums > Programming > PHP - Code
Forum Jump Register FAQ Members List Downloads Search Today's Posts Mark Forums Read

PHP - Code PHP programming - Ask questions and help people with PHP code. If you are stuck and need help, this is where you ask for help.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 6th September 2008, 16:56
JQL JQL is offline
D4PHP User
 
Join Date: Aug 2008
Posts: 21
JQL is on a distinguished road
Default FormValidator and Regular Expressions

The FormValidator has a section for ValidationType into which you can enter a Regular Expression. Being very "green" when it comes to Regular Expressions how would I enter the [:alnum:] regular expression into this field?

I've tried just entering [:alnum:] in the field but that doesn't work...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 7th September 2008, 00:26
405hp's Avatar
Firebug Fanatic
 
Join Date: Dec 2007
Location: State of Confusion
Posts: 3,480
405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute
Default

afaik alnum isn't anything in javascript.

how to: http://javascript.about.com/od/regul...xpressions.htm
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 11th September 2008, 10:45
JQL JQL is offline
D4PHP User
 
Join Date: Aug 2008
Posts: 21
JQL is on a distinguished road
Default

[:alnum:] = [A-Za-z0-9] = Alphanumeric characters

So how do I use [A-Za-z0-9] in Validator ValidationType?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 11th September 2008, 14:26
405hp's Avatar
Firebug Fanatic
 
Join Date: Dec 2007
Location: State of Confusion
Posts: 3,480
405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute
Default

http://developer.berlios.de/forum/me...p?msg_id=16337
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 1st October 2008, 09:38
D4PHP User
 
Join Date: May 2008
Posts: 15
apajax is on a distinguished road
Default

In my opinion there is a bug at all with regexp on line 219 in formvalidator.inc.php unit:

PHP Code:
  echo "obj.regexp=\"$regexp\";\n"
removing the double quotes makes javascript handling the regexp right, so the code on line 208 should be...

PHP Code:
                  if($regexp{0} == '/')
                    echo 
"obj.regexp=$regexp;\n";
                  else
                  {
                        switch(
$regexp)
                        {
                                case 
'email'$regexp='JSVAL_RX_EMAIL'; break;
                                  case 
'telephone':$regexp='JSVAL_RX_TEL'; break;
                                  case 
'zip':$regexp='JSVAL_RX_ZIP'; break;
                                  case 
'money':$regexp='JSVAL_RX_MONEY'; break;
                                  case 
'creditcard':$regexp='JSVAL_RX_CREDITCARD'; break;
                                  case 
'postalzip':$regexp='JSVAL_RX_POSTALZIP'; break;
                                  case 
'postalcode':$regexp='JSVAL_RX_PC'; break;
                        }

                    echo 
"obj.regexp=\"$regexp\";\n";
                  } 

Last edited by apajax; 1st October 2008 at 10:01.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 1st October 2008, 17:19
405hp's Avatar
Firebug Fanatic
 
Join Date: Dec 2007
Location: State of Confusion
Posts: 3,480
405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute
Default

Looks right. Send your fix to support@qadram.com

BTW these are the built in reg expressions that it uses:
Quote:
function _checkRegExp(regx,value){
switch(regx){
case "JSVAL_RX_EMAIL":
return((/^[a-zA-Z0-9]+([\.-]?[a-zA-Z0-9]+)*@[a-zA-Z0-9]+([\.-]?[a-zA-Z0-9]+)*(\.\w{2,5})+$/).test(value));
case "JSVAL_RX_TEL":
return((/^1?[\-]?\(?\d{3}\)?[\-]?\d{3}[\-]?\d{4}$/).test(value));
case "JSVAL_RX_PC":
return((/^[a-z]\d[a-z]?\d[a-z]\d$/i).test(value));
case "JSVAL_RX_ZIP":
return((/^\d{5}$/).test(value));
case "JSVAL_RX_MONEY":
return((/^\d+([\.]\d\d)?$/).test(value));
case "JSVAL_RX_CREDITCARD":
return(!isNaN(value));
case "JSVAL_RX_POSTALZIP":
if(value.length==6||value.length==7)
return((/^[a-zA-Z]\d[a-zA-Z] ?\d[a-zA-Z]\d$/).test(value));
if(value.length==5||value.length==10)
return((/^\d{5}(\-\d{4})?$/).test(value));
break;
default:
return(regx.test(value));
};
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 2nd October 2008, 15:36
JQL JQL is offline
D4PHP User
 
Join Date: Aug 2008
Posts: 21
JQL is on a distinguished road
Default

Many thanks apajax! That seems to have sorted it.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 11th November 2008, 14:42
just Joined!
 
Join Date: Nov 2008
Posts: 1
homutke is on a distinguished road
Default

Quote:
Originally Posted by 405hp View Post
Looks right. Send your fix to support@qadram.com

BTW these are the built in reg expressions that it uses:
Problem RXMAIL?
How to work with names
test_test@test.com or A.test@test.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 11th November 2008, 17:33
405hp's Avatar
Firebug Fanatic
 
Join Date: Dec 2007
Location: State of Confusion
Posts: 3,480
405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute
Default

Not sure I understand what you mean, but if so...

You could probably change the reg expression on the validator.

This is what I use for email validation:
Code:
                emailRe = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/;
I made up a button to check yours vs both of the reg expressions and the test_test@ comes out false with the validator and true with the one I use.

Code:
              var value="A.test@test.com";
               //var value="test_test@test.com";
               alert((/^[a-zA-Z0-9]+([\.-]?[a-zA-Z0-9]+)*@[a-zA-Z0-9]+([\.-]?[a-zA-Z0-9]+)*(\.\w{2,5})+$/).test(value));
                emailRe = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/;
                if (!emailRe.test(value))
                 {
                 alert(value + ' is invalid');
                 return(false);
                 }
                alert(emailRe.test(value));
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT +1. The time now is 04:51.




Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0 ©2009, Crawlability, Inc.
Copyright © 2004 - 2009, G&J Solutions Ltd. All Rights Reserved. terms of use