• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Javascript Help: Regular Expressions?

ragazzo

Golden Member
If I want a function to check that the number entered is exactly 8 digits long, how would I do it?

I tried:

/^\d{8}

but that only checks up to 8 digits. You can enter 9 or more and it'll pass true. Thanks in advance!
 
thanks, but Mozilla threw an err msg:

Error: syntax error
Source File: js2.html

Source Code:
re = ^\d{8}$
 
I gave you a valid regular expression, I've never tried to use it in javascript for mozilla. I left off the leading "/" that you had, as it's not actually part of the expression, but if it's part of the syntax for regexes in mozilla's javascript, then you'll want to make sure you didn't take it out of your code.
 
Back
Top