shadiadiph Posted June 28, 2010 Share Posted June 28, 2010 Does a-z in regex validate european characters like French or German vowels that have the strange marks above them? Quote Link to comment Share on other sites More sharing options...
salathe Posted June 28, 2010 Share Posted June 28, 2010 No. Quote Link to comment Share on other sites More sharing options...
shadiadiph Posted June 28, 2010 Author Share Posted June 28, 2010 mm so how to get round this problem? how to validate european characters also? Quote Link to comment Share on other sites More sharing options...
shadiadiph Posted June 28, 2010 Author Share Posted June 28, 2010 or rather disallow characters $ % @ ! Quote Link to comment Share on other sites More sharing options...
cags Posted June 28, 2010 Share Posted June 28, 2010 You could simply ensure that the string doesn't contain those characters using [^$%@!] etc. Quote Link to comment Share on other sites More sharing options...
shadiadiph Posted June 28, 2010 Author Share Posted June 28, 2010 so how to check just for those characters? Quote Link to comment Share on other sites More sharing options...
shadiadiph Posted June 28, 2010 Author Share Posted June 28, 2010 just tried that /[^$%@!] / returns even the word dog as invalid if i check to see if the match is false seems to return everything as true Quote Link to comment Share on other sites More sharing options...
Alex Posted June 28, 2010 Share Posted June 28, 2010 if(!preg_match('~^[^$%@!]+$~', $str)) { // contains invalid characters } Quote Link to comment Share on other sites More sharing options...
shadiadiph Posted June 28, 2010 Author Share Posted June 28, 2010 thanks for the hint Alex but that will not work for me I just tried making it into a normal regex pattern couldn't get it to work. Trybing to actually do all my validation browser sided not server sided ?? Quote Link to comment Share on other sites More sharing options...
shadiadiph Posted June 28, 2010 Author Share Posted June 28, 2010 I just tried it like this but didn;t work var cityreg=/^[^$%@!]+$/; Quote Link to comment Share on other sites More sharing options...
Psycho Posted June 28, 2010 Share Posted June 28, 2010 <html> <head> <script type="text/javascript"> function invalidInput(text) { var invalidChars = /[$%@!]/ return invalidChars.test(text); } function checkInput() { var inputText = document.getElementById('input').value; if(invalidInput(inputText)) { alert('Input was NOT valid'); } else { alert('Input was valid'); } return; } </script> </head> <body> Input: <input type="text" name="input" id="input" /> <br /> <button onclick="checkInput();">Test</button> </body> </html> Quote Link to comment Share on other sites More sharing options...
shadiadiph Posted June 29, 2010 Author Share Posted June 29, 2010 Thanks mjdamato and everyone else who contributed. 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.