Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Wednesday, November 11, 2026
About Us
Magazine
Open Source
CVS
Services
Index  »  Projects  »  phpMyEdit  »  Forum  »  problem using regular expression

phpMyEdit General     problem using regular expression
Post new topic   Reply to topic    
 
tsrwebmanager     Joined: 26 Apr 2008   Posts: 2  
Post Posted: 2008-04-28 11:58
Back to top  Reply with quote     

I have found that, when using a regular expression for field validation, if the regexp is reasonably simple there is no problem, but with a complex regex the process doesn't always work.

Does any one have a regex to validat email addresses that works?

May I suggest a revision to the code (the following is for validating a numeric field, it works as is - but I use it as an example) so that the JSCript generated uses a variable for the regex. i.e for a simple regex of
Quote:
/^[0-9]*$/
instead of generating
Code:
   if (PME_js_trim(theForm.PME_data_mship_no.value) == "" || !(/^[0-9]*$/.test(PME_js_trim(theForm.PME_data_mship_no.value)))) {
      alert("Membership number MUST be unique, and contain only digits 0-9.");
      theForm.PME_data_mship_no.focus();
      return false;
   }
you generate

Code:
   PME_data_mship_no_regex='/^[0-9]*$/';
   if (PME_js_trim(theForm.PME_data_mship_no.value) == "" || !(PME_data_mship_no_regex.test(PME_js_trim(theForm.PME_data_mship_no.value)))) {
      alert("Membership number MUST be unique, and contain only digits 0-9.");
      theForm.PME_data_mship_no.focus();
      return false;
   }

This would better facilitate the use of complex reg expressions

 
Post new topic   Reply to topic    

Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top · Feedback form · Application form
Report bug on PLATON.SK website · Terms of use · Privacy policy