473,394 Members | 1,751 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Need a fresh set of eyes on a Javasript edit

Hello All, I'm getting frustrated with the syntax of a jscript edit I'm using on a VBScript page. Here is what I have:

var re = /[$\\@\\\#%\^\&\*\(\)\[\]\+\_\{\}\`\~\=\|]/;
if (!re.test(document.login.NewUserPassword.value))
{
AlertMessage += "Invalid entry! You must also use nonalphanumeric characters!";
focusfield =document.login.NewUserPassword;
}

and when I run it I get "error: undefined is "null" or not an object"

Basically, it is a password reset page and one of the rules is that the new p-word has to have non-alphanumerics in it. I know it is something minor, but I have stared at it so long

Thanks in advance for your ideas!
Jun 26 '07 #1
5 1251
epots9
1,351 Expert 1GB
this is just a shot in the dark but maybe add quotes:
Expand|Select|Wrap|Line Numbers
  1. var re = "/[$\\@\\\#%\^\&\*\(\)\[\]\+\_\{\}\`\~\=\|]/";
  2.  
and what is test? can u post its source?

good luck
Jun 26 '07 #2
Thanks for your speedy reply! It is syntax I borrowed from a site that has lots of javascript examples. The specific one I borrowed from looked like this:

var re = /[$\\@\\\#%\^\&\*\(\)\[\]\+\_\{\}\`\~\=\|]/
if (!re.test(str)) return false;

I thought that "test" was a function. I'm open to doing it another way, just thought that this looked pretty straightforward!

The funny things is I had this thing somewhat working on Friday, and now it doesn't work!
Jun 26 '07 #3
gits
5,390 Expert Mod 4TB
hi ...

yes ... test() is a build in js-method that may be used the following way:

Expand|Select|Wrap|Line Numbers
  1. // regEx that requires all chars as numeric
  2. var re = /^\d+$/; 
  3.  
  4. // this returns true
  5. re.test('111');
  6.  
  7. // this returns false
  8. re.test('111a');
  9.  
kind regards ...
Jun 26 '07 #4
gits
5,390 Expert Mod 4TB
... i tested your regEx ... it seems to be ok ... may be your value is not referenced correctly? is document.login.NewUserPassword defined in your page?

kind regards ...
Jun 26 '07 #5
Thank you so much for your help. This what I ended up using:

if (!((document.login.NewUserPassword.value.search(/[a-z]+/) > -1) && (document.login.NewUserPassword.value.search(/[A-Z]+/) > -1) && (document.login.NewUserPassword.value.search(/[0-9]+/) > -1) && (document.login.NewUserPassword.value.search(/[^a-zA-Z0-9_]+/) > -1)))


and it is working well

Thanks for sharing your knowledge!
Jun 29 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Bruce D | last post by:
Here's the breakdown: MySQL 4.0.12 Table: Assignment (indexes are created on proper fields) 419,234 records Table: Finders (indexes are created on proper fields) 5,345,657 records My user wants...
11
by: Laiverd.COM | last post by:
Hi, In the following function I keep getting a 'Object expected at line 75 char 5' but for the life of me I cannot find the error. Maybe someone would be so kin to have a look? I indicated the...
5
by: jensen bredal | last post by:
I need to keep track on user "session data" while still turning session off as i do not want users login to expire? Thanks JB
0
by: shinichi | last post by:
Hi all, Im an Oracle newbie here. I have questions here that need guidance from Oracle Expert here. Here it goes: - there are 3 databases that will be used: tableA (2000 records), tableAsub (45000...
0
by: U S Contractors Offering Service A Non-profit | last post by:
Brilliant technology helping those most in need Inbox Reply U S Contractors Offering Service A Non-profit show details 10:37 pm (1 hour ago) Brilliant technology helping those most in need ...
20
by: mike | last post by:
I help manage a large web site, one that has over 600 html pages... It's a reference site for ham radio folks and as an example, one page indexes over 1.8 gb of on-line PDF documents. The site...
1
by: bomahony | last post by:
Ive just installed DB2 9.1 from scratch on Solaris 10. I did it first from CLI, but i found the Control Center app was missing. So i tried to edit the install using db2setup. this informed me...
2
by: pbd22 | last post by:
Hi. I have been wrestling with a problem for over a week now and I think I need to breathe and rethink my approach. I am wondering if somebody wouldn't mind telling me how they would tackle...
7
by: ojsimon | last post by:
Hi I found this script on a forum and have been trying to make it work, but all it returns is a blank screen, i tried using the debug error reporting but got nothing from that either just a blank...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.