FAQ
Edit report at http://pear.php.net/bugs/bug.php?id=5308&edit=1

ID: 5308
Updated by: daniel.oconnor@gmail.com
Reported By: maarten at xolphin dot nl
Summary: Javascript Validation with Ajax
Status: Open
Type: Feature/Change Request
Package: HTML_QuickForm2
Operating System: Irrelevant
PHP Version: Irrelevant
Roadmap Versions:
New Comment:

An alternative which may be more practical is a renderer which is aware
of
HTML5.

http://diveintohtml5.org/forms.html and
http://www.w3schools.com/html5/html5_form_attributes.asp

For simple cases such as required fields, simple regexp patterns, title
attributes,
HTML5 can support this without the need for javascript.

$form->addElement('text', 'name');
$form->addRule('name', '[a-zA-Z]');

print $form; // On rendering, a pattern attribute is added to the name
field; or via
the DOM.


Previous Comments:
------------------------------------------------------------------------

[2006-06-08 09:24:45] avb

Moving feature requests to HTML_QuickForm2.

------------------------------------------------------------------------

[2005-09-06 05:29:50] xolphin

Description:
------------
At the moment HTML_QuickForm uses some Javascript validation if wanted
on the OnSubmit of the form. This saves some time checking the form on
the server, but it looks nasty. The user has to read the alert created
by the JavaScript, and has to find the form element where the error is
in.

Ajax is a development methodology focused on removing click and wait in
web applications. I won't explain it here, because there is already a
lot of information available on it.

I think Ajax can be used in HTML_QuickForm very good. With Ajax we could
get the folowing advantages:

- Validation code only has to be written ones, and is executed on the
server (without the need to submit anything). We don't need a php
validation seperate from a javascript validation anymore.
- Code can be checked realtime, while the user is filling in the form.
He can instantly see he has done something wrong. Of course this can be
made with normal JavaScript too, but Ajax makes it some easier.
- Auto completion can be done with realtime data, instead of auto
completion with static data which is already possible now.

A nice example of what can be done with Ajax can be found on
http://www.khelder.com/tutorials/smartvalidation/ . For better
clarification the form elements with errors can be colored for example
yellow or orange. But that is up to the developer.

I hope this is the right place to make such a suggestion, if this is
better of in another place, please let me know. I like the Ajax idea a
lot and if needed I am willing to code it into HTML_QuickForm. Below
some useful links with more info of Ajax.

Validation with Ajax:
http://particletree.com/features/smart-validation-with-ajax

Ajax information:
http://www.sergiopereira.com/articles/prototype.js.html

How Ajax works:
http://www.adaptivepath.com/publications/essays/archives/000385.php

Ways to implement it:
http://particletree.com/features/a-guide-to-unobtrusive-javascript

Pear implementation:
http://blog.joshuaeichorn.com/HTML_AJAX

------------------------------------------------------------------------

Search Discussions

  • Daniel Oconnor at Mar 27, 2011 at 6:40 am
    Edit report at http://pear.php.net/bugs/bug.php?id=5308&edit=1

    ID: 5308
    Updated by: daniel.oconnor@gmail.com
    Reported By: maarten at xolphin dot nl
    Summary: Javascript Validation with Ajax
    Status: Open
    Type: Feature/Change Request
    Package: HTML_QuickForm2
    Operating System: Irrelevant
    PHP Version: Irrelevant
    Roadmap Versions:
    New Comment:

    Request #17842


    Previous Comments:
    ------------------------------------------------------------------------

    [2011-03-27 07:22:32] doconnor

    An alternative which may be more practical is a renderer which is aware
    of
    HTML5.

    http://diveintohtml5.org/forms.html and
    http://www.w3schools.com/html5/html5_form_attributes.asp

    For simple cases such as required fields, simple regexp patterns, title
    attributes,
    HTML5 can support this without the need for javascript.

    $form->addElement('text', 'name');
    $form->addRule('name', '[a-zA-Z]');

    print $form; // On rendering, a pattern attribute is added to the name
    field; or via
    the DOM.

    ------------------------------------------------------------------------

    [2006-06-08 09:24:45] avb

    Moving feature requests to HTML_QuickForm2.

    ------------------------------------------------------------------------

    [2005-09-06 05:29:50] xolphin

    Description:
    ------------
    At the moment HTML_QuickForm uses some Javascript validation if wanted
    on the OnSubmit of the form. This saves some time checking the form on
    the server, but it looks nasty. The user has to read the alert created
    by the JavaScript, and has to find the form element where the error is
    in.

    Ajax is a development methodology focused on removing click and wait in
    web applications. I won't explain it here, because there is already a
    lot of information available on it.

    I think Ajax can be used in HTML_QuickForm very good. With Ajax we could
    get the folowing advantages:

    - Validation code only has to be written ones, and is executed on the
    server (without the need to submit anything). We don't need a php
    validation seperate from a javascript validation anymore.
    - Code can be checked realtime, while the user is filling in the form.
    He can instantly see he has done something wrong. Of course this can be
    made with normal JavaScript too, but Ajax makes it some easier.
    - Auto completion can be done with realtime data, instead of auto
    completion with static data which is already possible now.

    A nice example of what can be done with Ajax can be found on
    http://www.khelder.com/tutorials/smartvalidation/ . For better
    clarification the form elements with errors can be colored for example
    yellow or orange. But that is up to the developer.

    I hope this is the right place to make such a suggestion, if this is
    better of in another place, please let me know. I like the Ajax idea a
    lot and if needed I am willing to code it into HTML_QuickForm. Below
    some useful links with more info of Ajax.

    Validation with Ajax:
    http://particletree.com/features/smart-validation-with-ajax

    Ajax information:
    http://www.sergiopereira.com/articles/prototype.js.html

    How Ajax works:
    http://www.adaptivepath.com/publications/essays/archives/000385.php

    Ways to implement it:
    http://particletree.com/features/a-guide-to-unobtrusive-javascript

    Pear implementation:
    http://blog.joshuaeichorn.com/HTML_AJAX

    ------------------------------------------------------------------------

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedMar 27, '11 at 6:20a
activeMar 27, '11 at 6:40a
posts2
users1
websitepear.php.net

1 user in discussion

Daniel Oconnor: 2 posts

People

Translate

site design / logo © 2022 Grokbase