This topic is locked

Time Field +MYSQL

9/2/2005 7:41:17 AM
PHPRunner General questions
K
kellyho67 author

I'm trying to make an add screen that takes date (using the build in picker) and then a field for time.
I need to allow the user to type

1:00PM or 13:00
Then have a javascript validate it on enter to format it as mysql needs it.
I've tried several things but can't seem to find where to put the validation.

Sergey Kornilov admin 9/6/2005

Kelly,
unfortunatelly PHPRunner doesn't support validation for TIME fields now.
However you can add your javascript code to unsubmitevent handler of editform form on Edit and Add pages.

K
kellyho67 author 9/7/2005

Ok, I found the onsubmit portion.

<form name="editform" encType="multipart/form-data" method="post" action=data_add.php onSubmit=" return validate();">
Are you saying that I should now update the validate() method to do this?

K
kellyho67 author 9/7/2005

I think rather than on submit I'd like to tie the onblur event from the particular form field to a Javascript I have created. I'm not seeing were I do that part in the code.
I assume it's in my add page but not really seeing where.

Sergey Kornilov admin 9/9/2005

Hi,
<input> element is created by BuildEditControl in include\..._finctions.php file.

Here is the snippet you can modify. Please see my changes in bold

if($format==EDIT_FORMAT_TEXT_FIELD)

{

    if("timefield"==$field)

        return '<input type="text" name="value'.$ifield.'" '.GetEditParams($field).' value="'.htmlspecialchars($value).'" onblur="return testtime(this.value);">';


    if(IsDateFieldType($type))

        return '<input type="hidden" name="type'.$ifield.'" value="date'.DateEditType($field).'">'.GetDateEdit($field,$value,0,$ifield,$edit);

    return '<input type="text" name="value'.$ifield.'" '.GetEditParams($field).' value="'.htmlspecialchars($value).'">';

}


where timefield is your field name and testtime is your validation function

K
kellyho67 author 9/9/2005

Great, that make perfect sense. Thanks for the kickstart shouldn't be any problem from there.