September 02, 2010, 09:08:45 pm *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Always search the forum before posting !
 
   Home   Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Wierd validation script error  (Read 1428 times)
Captain Paralytic
Supporter
Full Member
*****
Offline Offline

Posts: 226



« on: June 29, 2006, 11:14:09 am »

I have a (big) form that has a regex validation for a phone number field.

This works fine when served from the apache server on my PC.

However, if I try to use it up on the web, IE tells me that it has an "unexpected qualifier" error.

This is a bit of a disaster so can anyone point me to a solution please?

Attached is a simple test package. Once again this works fine on my PC but fails when served from the web.

I have traced the problem to the Compress JavaScript and HTML setting. The error occurs when I have it set to compress!

Any idea how I can use the compression but still have a successful validation?

* phtest.xml (1.8 KB - downloaded 95 times.)
« Last Edit: June 29, 2006, 11:26:50 am by Captain Paralytic » Logged
facile
Administrator
Hero Member
*****
Offline Offline

Posts: 774



« Reply #1 on: June 29, 2006, 11:30:51 am »

It appears that the blank gets stripped out of the regex when javascript compression is enabled.

Disabling compression in the FacileForms configuration works around the problem until a better fix is found.

Edit:

change the line

Code:
var ex  = /^(\+[1-9][0-9]* *(\([0-9]*\) *|-[0-9]*-))?[0]?[1-9][0-9\- ]*$/;

to

Code:
var ex  = new RegExp("^(\+[1-9][0-9]* *(\([0-9]*\) *|-[0-9]*-))?[0]?[1-9][0-9\- ]*$");
« Last Edit: June 29, 2006, 11:36:45 am by facile » Logged

Peter
Captain Paralytic
Supporter
Full Member
*****
Offline Offline

Posts: 226



« Reply #2 on: June 29, 2006, 11:36:15 am »

I found a way around it.
In the before form piece I put

echo '
<script type="text/javascript">
phtst = /^(\+[1-9][0-9]*\ *(\([0-9]*\)\ *|-[0-9]*-))?[0]?[1-9][0-9\- ]*$/
</script>'

and used the phtst global.
Logged
facile
Administrator
Hero Member
*****
Offline Offline

Posts: 774



« Reply #3 on: June 29, 2006, 11:42:24 am »

Sorry there is a bug in my suggestion. You need to duplicate all backslashes for the alternate syntax which is compatible with compression:

Code:
var ex  = new RegExp("^(\\+[1-9][0-9]* *(\\([0-9]*\\) *|-[0-9]*-))?[0]?[1-9][0-9\\- ]*$");
Logged

Peter
Captain Paralytic
Supporter
Full Member
*****
Offline Offline

Posts: 226



« Reply #4 on: June 29, 2006, 11:55:57 am »

Thanks for that Peter. Mind you since I use the check on 2 fields, the global var seems a good idea for now, but I'll remember your hint for any other single fields.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by SMF © 2001-2006 Lewis Media
| Terms of Use | Privacy | Sitemap |