edi Posted July 9, 2010 Report Share Posted July 9, 2010 ka lai parbauda vai logins nesatur tikai skaitlus? vajag ta lai butu pieejams logins tikai ar latinu alfabeta burtiem un +var vel ar cipariem bet nebutu pieejams tikai ar cipariem preg_match("",$login); Quote Link to comment Share on other sites More sharing options...
briedis Posted July 9, 2010 Report Share Posted July 9, 2010 (edited) Uz fikso šitādu izdomāju.. Vārdam obligāti jāsākas ar visamz vienu burtu. Tālāk var būt gan burti, gan cipari... (mazie burti) ^[a-z][0-9a-z]*$ Edited July 9, 2010 by briedis Quote Link to comment Share on other sites More sharing options...
edi Posted July 9, 2010 Author Report Share Posted July 9, 2010 (edited) ar tavu piemeru meginot izvada erroru :) No ending delimiter '^' sadi meginot preg_match("/^[a-z][0-9a-z]*$/", $reg_nick) nekadas reakcijas sadi preg_match("/[^a-z][0-9a-z]*$/", $reg_nick) rada ka visi ir skaitli :D un sadi preg_match("/[^\da-z][0-9a-z]+/", $reg_nick) neko nerada (: if (preg_match("/^[a-z][0-9a-z]*$/", $reg_nick)) $error = $error . 'Logins nevar sastāvēt tikai no cipariem!<br/>'; tad ka bus pareizi? :D Edited July 9, 2010 by edi Quote Link to comment Share on other sites More sharing options...
briedis Posted July 9, 2010 Report Share Posted July 9, 2010 (edited) Ko sāsti, ka manējais nestrādā? var_dump(preg_match('/^[a-zA-Z][0-9a-zA-Z]*$/', "MansSuperniks")); var_dump(preg_match('/^[a-zA-Z][0-9a-zA-Z]*$/', "34543")); var_dump(preg_match('/^[a-zA-Z][0-9a-zA-Z]*$/', "IrOk342354")); var_dump(preg_match('/^[a-zA-Z][0-9a-zA-Z]*$/', "34432NavOk")); var_dump(preg_match('/^[a-zA-Z][0-9a-zA-Z]*$/', "s34432Na45vOk567")); Viss strādā kā nākas! (manā gadījumā, niks nevar sākties ar ciparu) Edited July 9, 2010 by briedis Quote Link to comment Share on other sites More sharing options...
edi Posted July 9, 2010 Author Report Share Posted July 9, 2010 Ko sāsti, ka manējais nestrādā? var_dump(preg_match('/^[a-zA-Z][0-9a-zA-Z]*$/', "MansSuperniks")); var_dump(preg_match('/^[a-zA-Z][0-9a-zA-Z]*$/', "34543")); var_dump(preg_match('/^[a-zA-Z][0-9a-zA-Z]*$/', "IrOk342354")); var_dump(preg_match('/^[a-zA-Z][0-9a-zA-Z]*$/', "34432NavOk")); var_dump(preg_match('/^[a-zA-Z][0-9a-zA-Z]*$/', "s34432Na45vOk567")); Viss strādā kā nākas! (manā gadījumā, niks nevar sākties ar ciparu) $reg_nick = '34432NavOk'; if (preg_match("/^[a-zA-Z][0-9a-zA-Z]*$/", $reg_nick)) $error = $error . 'Logins nevar sakties ar ciparu!<br/>'; tu neticesi :D izgaja cauri Quote Link to comment Share on other sites More sharing options...
briedis Posted July 9, 2010 Report Share Posted July 9, 2010 Es tiešām neticēšu! Jo man neiet cauri :) Ieteikums - visiem IF'iem lieto {} iekavas, lai izvairītos no pārpratumiem nākotnē :) Quote Link to comment Share on other sites More sharing options...
edi Posted July 10, 2010 Author Report Share Posted July 10, 2010 (edited) Es tiešām neticēšu! Jo man neiet cauri :) Ieteikums - visiem IF'iem lieto {} iekavas, lai izvairītos no pārpratumiem nākotnē :) <?php $reg_nick = '34432NavOk'; if (preg_match("/^[a-zA-Z][0-9a-zA-Z]*$/", $reg_nick)) { echo 'error'; } ?> izmegini. tev error izvadija? pamaniju ka vins vispar preteji dara.... ja niks nesakas ar skaitli tad error :D Edited July 10, 2010 by edi Quote Link to comment Share on other sites More sharing options...
marcis Posted July 10, 2010 Report Share Posted July 10, 2010 Man sanāca šitā /(?=^[a-z\d]+$).*\D/ Quote Link to comment Share on other sites More sharing options...
edi Posted July 10, 2010 Author Report Share Posted July 10, 2010 Man sanāca šitā /(?=^[a-z\d]+$).*\D/ pieliku brieza variantam vienkasi not klat un viss) Quote Link to comment Share on other sites More sharing options...
marcis Posted July 10, 2010 Report Share Posted July 10, 2010 Mans variants ir labāks ar to, ka nenosaka, ka pirmajam simbolam noteikti jābūt burtam, tas var būt arī cipars, taču paliek pie nosacījuma, ka visi simboli nedrīkst būt cipari. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.