The following warnings occurred:
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.27 (Linux)
File Line Function
/global.php 783 errorHandler->error
/showthread.php 26 require_once
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.27 (Linux)
File Line Function
/global.php 783 errorHandler->error
/showthread.php 26 require_once
Warning [2] Undefined variable $newpmmsg - Line: 40 - File: global.php(841) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/global.php(841) : eval()'d code 40 errorHandler->error
/global.php 841 eval
/showthread.php 26 require_once
Warning [2] Undefined array key "style" - Line: 909 - File: global.php PHP 8.1.27 (Linux)
File Line Function
/global.php 909 errorHandler->error
/showthread.php 26 require_once
Warning [2] Undefined property: MyLanguage::$lang_select_default - Line: 5024 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 5024 errorHandler->error
/global.php 909 build_theme_select
/showthread.php 26 require_once
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions.php 5044 is_member
/global.php 909 build_theme_select
/showthread.php 26 require_once
Warning [2] Undefined array key 1 - Line: 1415 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 1415 errorHandler->error
/inc/functions.php 1380 fetch_forum_permissions
/inc/functions.php 2909 forum_permissions
/showthread.php 621 build_forum_jump
Warning [2] Undefined array key 1 - Line: 1415 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 1415 errorHandler->error
/inc/functions.php 1380 fetch_forum_permissions
/inc/functions.php 2909 forum_permissions
/showthread.php 621 build_forum_jump
Warning [2] Undefined array key 1 - Line: 1415 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 1415 errorHandler->error
/inc/functions.php 1380 fetch_forum_permissions
/inc/functions.php 2909 forum_permissions
/showthread.php 621 build_forum_jump
Warning [2] Undefined array key 1 - Line: 1415 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 1415 errorHandler->error
/inc/functions.php 1380 fetch_forum_permissions
/inc/functions.php 2909 forum_permissions
/showthread.php 621 build_forum_jump
Warning [2] Undefined array key 1 - Line: 1415 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 1415 errorHandler->error
/inc/functions.php 1380 fetch_forum_permissions
/inc/functions.php 2909 forum_permissions
/showthread.php 621 build_forum_jump
Warning [2] Undefined array key 1 - Line: 1415 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 1415 errorHandler->error
/inc/functions.php 1380 fetch_forum_permissions
/inc/functions.php 2909 forum_permissions
/showthread.php 621 build_forum_jump
Warning [2] Undefined array key "mybb" - Line: 1952 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 1952 errorHandler->error
/inc/functions_indicators.php 41 my_set_array_cookie
/showthread.php 629 mark_thread_read
Warning [2] Undefined property: MyLanguage::$ratings_update_error - Line: 5 - File: showthread.php(732) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/showthread.php(732) : eval()'d code 5 errorHandler->error
/showthread.php 732 eval
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions_user.php 844 is_member
/inc/functions_post.php 406 purgespammer_show
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "profilefield" - Line: 6 - File: inc/functions_post.php(474) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php(474) : eval()'d code 6 errorHandler->error
/inc/functions_post.php 474 eval
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "canonlyreplyownthreads" - Line: 660 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 660 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showimages" - Line: 741 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 741 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showvideos" - Line: 746 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 746 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions_user.php 844 is_member
/inc/functions_post.php 406 purgespammer_show
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "profilefield" - Line: 6 - File: inc/functions_post.php(474) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php(474) : eval()'d code 6 errorHandler->error
/inc/functions_post.php 474 eval
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "canonlyreplyownthreads" - Line: 660 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 660 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showimages" - Line: 741 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 741 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showvideos" - Line: 746 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 746 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions_user.php 844 is_member
/inc/functions_post.php 406 purgespammer_show
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "profilefield" - Line: 6 - File: inc/functions_post.php(474) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php(474) : eval()'d code 6 errorHandler->error
/inc/functions_post.php 474 eval
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "canonlyreplyownthreads" - Line: 660 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 660 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showimages" - Line: 741 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 741 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showvideos" - Line: 746 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 746 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions_user.php 844 is_member
/inc/functions_post.php 406 purgespammer_show
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "profilefield" - Line: 6 - File: inc/functions_post.php(474) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php(474) : eval()'d code 6 errorHandler->error
/inc/functions_post.php 474 eval
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "canonlyreplyownthreads" - Line: 660 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 660 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showimages" - Line: 741 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 741 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showvideos" - Line: 746 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 746 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions_user.php 844 is_member
/inc/functions_post.php 406 purgespammer_show
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "profilefield" - Line: 6 - File: inc/functions_post.php(474) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php(474) : eval()'d code 6 errorHandler->error
/inc/functions_post.php 474 eval
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "canonlyreplyownthreads" - Line: 660 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 660 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showimages" - Line: 741 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 741 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showvideos" - Line: 746 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 746 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions_user.php 844 is_member
/inc/functions_post.php 406 purgespammer_show
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "profilefield" - Line: 6 - File: inc/functions_post.php(474) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php(474) : eval()'d code 6 errorHandler->error
/inc/functions_post.php 474 eval
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "canonlyreplyownthreads" - Line: 660 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 660 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showimages" - Line: 741 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 741 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showvideos" - Line: 746 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 746 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showimages" - Line: 784 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 784 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "invisible" - Line: 1506 - File: showthread.php PHP 8.1.27 (Linux)
File Line Function
/showthread.php 1506 errorHandler->error
Warning [2] Undefined variable $threadnotesbox - Line: 30 - File: showthread.php(1533) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/showthread.php(1533) : eval()'d code 30 errorHandler->error
/showthread.php 1533 eval
Warning [2] Undefined variable $addremovesubscription - Line: 79 - File: showthread.php(1533) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/showthread.php(1533) : eval()'d code 79 errorHandler->error
/showthread.php 1533 eval



FORUMS


The Form Tools forums are no longer active, but the old posts have been archived here. Please see the Help page on how to get help / report issues.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
time validation
#1
Question 
[size=x-small]
Hello there,

Maybe a silly question from a newbie.....
Anyone knows how to implement a RSV rule to compare two time values?
format: hh:mm.

I would like to prevent users to fill in wrong time values (time in textbox2 earlier then time in textbox1)

Code:
</select> <select name="BW" style=
    "position:absolute;left:300px;top:35px;width:80px;z-index:50; height: 20px;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: xx-small; font-style: normal; font-variant: normal; font-weight: normal">
    <option value=""></option>
      <option value="06:00">
        06:00
      </option>

      <option value="06:15">
        06:15
      </option>

      <option value="06:30">
        06:30
      </option>

      <option value="06:45">
        06:45
      </option>

      <option value="07:00">
        07:00
      </option>

      <option value="07:15">
        07:15
      </option>

      <option value="07:30">
        07:30
      </option>

      <option value="07:45">
        07:45
      </option>

      <option value="08:00">
        08:00
      </option>

      <option value="08:15">
        08:15
      </option>

      <option value="08:30">
        08:30
      </option>

      <option value="08:45">
        08:45
      </option>

      <option value="09:00">
        09:00
      </option>

      <option value="09:15">
        09:15
      </option>

      <option value="09:30">
        09:30
      </option>

      <option value="09:45">
        09:45
      </option>

      <option value="10:00">
        10:00
      </option>

      <option value="10:15">
        10:15
      </option>

      <option value="10:30">
        10:30
      </option>

      <option value="10:45">
        10:45
      </option>

      <option value="11:00">
        11:00
      </option>

      <option value="11:15">
        11:15
      </option>

      <option value="11:30">
        11:30
      </option>

      <option value="11:45">
        11:45
      </option>

      <option value="12:00">
        12:00
      </option>

      <option value="12:15">
        12:15
      </option>

      <option value="12:30">
        12:30
      </option>

      <option value="12:45">
        12:45
      </option>

      <option value="13:00">
        13:00
      </option>

      <option value="13:15">
        13:15
      </option>

      <option value="13:30">
        13:30
      </option>

      <option value="13:45">
        13:45
      </option>

      <option value="14:00">
        14:00
      </option>

      <option value="14:15">
        14:15
      </option>

      <option value="14:30">
        14:30
      </option>

      <option value="14:45">
        14:45
      </option>

      <option value="15:00">
        15:00
      </option>

      <option value="15:15">
        15:15
      </option>

      <option value="15:30">
        15:30
      </option>

      <option value="15:45">
        15:45
      </option>

      <option value="16:00">
        16:00
      </option>

      <option value="16:15">
        16:15
      </option>

      <option value="16:30">
        16:30
      </option>

      <option value="16:45">
        16:45
      </option>

      <option value="17:00">
        17:00
      </option>

      <option value="17:15">
        17:15
      </option>

      <option value="17:30">
        17:30
      </option>

      <option value="17:45">
        17:45
      </option>

      <option value="18:00">
        18:00
      </option>

      <option value="18:15">
        18:15
      </option>

      <option value="18:30">
        18:30
      </option>
    </select> <select name="VZ" style=
    "position:absolute;left:300px;top:75px;width:80px;z-index:51; height: 20px;;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: xx-small; font-style: normal; font-variant: normal; font-weight: normal">
    <option value=""></option>
      <option value="06:00">
        06:00
      </option>

      <option value="06:15">
        06:15
      </option>

      <option value="06:30">
        06:30
      </option>

      <option value="06:45">
        06:45
      </option>

      <option value="07:00">
        07:00
      </option>

      <option value="07:15">
        07:15
      </option>

      <option value="07:30">
        07:30
      </option>

      <option value="07:45">
        07:45
      </option>

      <option value="08:00">
        08:00
      </option>

      <option value="08:15">
        08:15
      </option>

      <option value="08:30">
        08:30
      </option>

      <option value="08:45">
        08:45
      </option>

      <option value="09:00">
        09:00
      </option>

      <option value="09:15">
        09:15
      </option>

      <option value="09:30">
        09:30
      </option>

      <option value="09:45">
        09:45
      </option>

      <option value="10:00">
        10:00
      </option>

      <option value="10:15">
        10:15
      </option>

      <option value="10:30">
        10:30
      </option>

      <option value="10:45">
        10:45
      </option>

      <option value="11:00">
        11:00
      </option>

      <option value="11:15">
        11:15
      </option>

      <option value="11:30">
        11:30
      </option>

      <option value="11:45">
        11:45
      </option>

      <option value="12:00">
        12:00
      </option>

      <option value="12:15">
        12:15
      </option>

      <option value="12:30">
        12:30
      </option>

      <option value="12:45">
        12:45
      </option>

      <option value="13:00">
        13:00
      </option>

      <option value="13:15">
        13:15
      </option>

      <option value="13:30">
        13:30
      </option>

      <option value="13:45">
        13:45
      </option>

      <option value="14:00">
        14:00
      </option>

      <option value="14:15">
        14:15
      </option>

      <option value="14:30">
        14:30
      </option>

      <option value="14:45">
        14:45
      </option>

      <option value="15:00">
        15:00
      </option>

      <option value="15:15">
        15:15
      </option>

      <option value="15:30">
        15:30
      </option>

      <option value="15:45">
        15:45
      </option>

      <option value="16:00">
        16:00
      </option>

      <option value="16:15">
        16:15
      </option>

      <option value="16:30">
        16:30
      </option>

      <option value="16:45">
        16:45
      </option>

      <option value="17:00">
        17:00
      </option>

      <option value="17:15">
        17:15
      </option>

      <option value="17:30">
        17:30
      </option>

      <option value="17:45">
        17:45
      </option>

      <option value="18:00">
        18:00
      </option>

      <option value="18:15">
        18:15
      </option>

      <option value="18:30">
        18:30
      </option>
    </select>
Reply
#2
Hey bvdveen,

For something custom like this, you'll definitely need to look into the custom function option. What that does is let you supplement the existing validation rules (required, valid email, is numeric, etc.) with your own custom ones. Check out the "custom validation rules" link on the top right of this page:
http://www.benjaminkeen.com/software/rsv/standalone/

Basically it works by adding a rule like so:

Code:
rules.push("function,check_times");

Then writing your own function that would do the manual labour of figuring out what was valid and what wasn't:

Code:
function check_times() {
  // do stuff here
}

The return values of that function need to be a particular format, as is described in that page above.

Hope this at least gets you on the right track...!

- Ben
Reply
#3
(Jan 16th, 2010, 11:45 AM)Ben Wrote: Hey bvdveen,

For something custom like this, you'll definitely need to look into the custom function option. What that does is let you supplement the existing validation rules (required, valid email, is numeric, etc.) with your own custom ones. Check out the "custom validation rules" link on the top right of this page:
http://www.benjaminkeen.com/software/rsv/standalone/

Basically it works by adding a rule like so:

Code:
rules.push("function,check_times");

Then writing your own function that would do the manual labour of figuring out what was valid and what wasn't:

Code:
function check_times() {
  // do stuff here
}

The return values of that function need to be a particular format, as is described in that page above.

Hope this at least gets you on the right track...!

- Ben

Hi Ben!

Thanks for your answer.
The problem - as you may have concluded already :-) - is that I an not sure how to write the code correctly. Believe me I have read over and over your example of a custom validation rule (prime numbers)
I simply don't know how to make sure my rule works.

I need something like:

field a = "begin_"time"
array: 06:00|06:15|06:30|06:45|07:00(etc).......|19:00
field b = "end_time"
array: 06:00|06:15|06:30|06:45|07:00(etc).......|19:00

rule: field b >= field a.

A solution I have thought of might be:

field a = begin_hour
array: 06|07|08|.....|19
field b = begin_minute
array:00|15|30|45
field c = end_hour
array: 06|07|08|....|19
field d = end_minute
array = 00|15|30|45

rule 1:
field c>=field a
rule 2:
field d<>field b

maybe with one more hint from you I could do it!
Sorry to have bothered you again with this...

Greetings

bvdveen
Reply
#4
Hey bvdveen,

No worries! It's always a bit rocky when you start programming.... but then you get hooked. Smile

I'd tackle the problem slightly differently, but your solution would work too. Take a look at the following code (I confess I haven't tested it, but the logic is sound):

Code:
function check_times()
{
    // get the values in the two dropdowns (you'll need to replace
    // "formnamehere" with the name attribute of your form)
    var time1 = document.formnamehere.BW.value;
    var time2 = document.formnamehere.VZ.value;
    
    // if either are empty, just do nothing. If the fields ARE required,
    // just add another RSV "required" rule BEFORE calling this custom function
    if (!time1 || !time2)
    {
        return true;
    }

    // split the info in each time on the ":" character
    var time1_info  = time1.split(":");
    var time1_hours = parseInt(time1_info[0]); // parseInt sucks, but it's OK here
    var time1_mins  = parseInt(time1_info[1]);
    
    var time2_info = time2.split(":");
    var time2_hours = parseInt(time2_info[0]);
    var time2_mins  = parseInt(time2_info[1]);
    
    // the error message is always going to be the same, so let's just stash it
    // in a variable here so we don't have to type it out multiple times.
    var errorInfo = [document.formnamehere.VZ, "Sorry, please enter a later time."];

    // alright! Now we do our validation. First check the hours: if the hour in time2
    // is less than time1, Houston we have a problem
    if (time2_hours < time1_hours)
    {
        return [errorInfo];
    }
    else if (time2_hours == time1_hours)
    {
        // here, the user entered the same hour for both. So,check that the
        // mins in time2 isn't greater of equal to that in time1
        if (time2_mins <= time1_mins)
        {
            return [errorInfo];
        }
    }

    // we're good!
    return true;    
}

Let me know how it goes!

- Ben
Reply
#5
You have given a good information. I really appreciate sharing this great post.This is really very helpful for me .
Reply
#6
Programing is my Life and I am crazy of programing.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)