Wednesday, June 5, 2024
 Popular · Latest · Hot · Upcoming
83
rated 0 times [  87] [ 4]  / answers: 1 / hits: 48247  / 15 Years ago, fri, february 12, 2010, 12:00:00

I am working on a php+javascript based project and have already made up a mockup page at :
my website



I knew how to use javascript or php to check whether a particular field of form is emptyor not, that is, whether it contains alphanumerical characters other than whitepsace characters(for instance, space, tab and newline).



However, my normal apporach no longer works since the jquery plugin that I am using now relies on regex to validate the fields.



If you go to the third tab(3. Fill up Shipping Info and Make Payment), you can enter something into the Firstname field and it does the check automatically. Fine. However, if
you just simply put some space characters there and jump to the next field, well, it still feels okay for that, which is not correct since no one's first name is nothing!



The problem? At the back it has a regex like this :



noSpecialCaracters:{
regex:/^[0-9a-zA-Z ]+$/,
alertText:* No special caracters allowed},


This would not filter out empty characters.



I searched online and tried my best to make up another regex to match, I tried



regex:/^[^]+$/


for matching non-empty characters, but that will not do...



Can anyone help me out? Many thanks in advance!


More From » jquery

 Answers
47

Try this for non-whitespace:



([^s]*)


Example:



/([^s])/.test(   A); //TRUE
/([^s])/.test( ); //FALSE

[#97595] Tuesday, February 9, 2010, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
parkernotnamedt

Total Points: 539
Total Questions: 90
Total Answers: 99

Location: Hong Kong
Member since Tue, Oct 19, 2021
3 Years ago
;