Welcome, Guest
Username: Password: Remember me

TOPIC: Regular expression problem

Regular expression problem 25 Feb 2012 21:29 #1447

  • VeCrea
  • VeCrea's Avatar
  • Offline
  • Platinum Member
  • Absolute JCook fan
  • Posts: 473
  • Thank you received: 100
  • Karma: 30
This is my regex : ^((0[0-9])|(1[0-9])|(2[0-3]))$
Quite simple, i use it to validate an hour field. Correct values are 00 to 23, with two figures everytime, even is hour < 10.
When I use this regex, it validates when i fill the fields in form view, but i use a number like 07, then it gives me an error on "save". So i have a green checkmark, but saves are not saved.
Any idea why this doesn't work ?
Thanks,
The administrator has disabled public write access.

Re: Regular expression problem 27 Feb 2012 13:37 #1465

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
Did you modified the RegEx after Cook generation ?

Because Cook Self Service write this RegEx in two different languages.
- In javascript (JDom script) -> Determines the green tick or not before to submit the form.
- In Php (in the table file : tables/mytable.php)

If you get the error on save(), you should have a look in the check() function of your table.php

Can you confirm you are looking in the table validation (check() method) ?

After that, watch carefully what string you furnish to the JDate() class.

That's all. If both points are corrects, it works.
Coding is now a piece of cake
Last Edit: 27 Feb 2012 13:38 by admin.
The administrator has disabled public write access.

Re: Regular expression problem 27 Feb 2012 17:54 #1471

  • VeCrea
  • VeCrea's Avatar
  • Offline
  • Platinum Member
  • Absolute JCook fan
  • Posts: 473
  • Thank you received: 100
  • Karma: 30
Thx for your answer.
No i did not modify RegEx after generation.
Do i still have to check the rest ?
^((0[0-9])|(1[0-9])|(2[0-3]))$ this won't work
^([0-9]|(1[0-9])|(2[0-3]))$ this works
The administrator has disabled public write access.
Time to create page: 0.071 seconds

Get Started