Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Streda, 25. november 2026
O nás
Magazín
Otvorený softvér
CVS
Služby
Index  »  Projekty  »  phpMyEdit  »  Fórum  »  problem using regular expression

phpMyEdit General     problem using regular expression
Odoslať novú tému   Odpovedať na tému    
 
tsrwebmanager     Založený: 26.04.2008   Príspevky: 2  
Príspevok Zaslal: 2008-04-28 11:58
Návrat hore  Odpovedať s citátom     

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
Citácia:
/^[0-9]*$/
instead of generating
Kód:
   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

Kód:
   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

 
Odoslať novú tému   Odpovedať na tému    

Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok · Odkazový formulár · Prihláška
Upozorniť na chybu na PLATON.SK webstránke · Podmienky použitia · Ochrana osobných údajov