PHP Classes

AJAX validation update

Recommend this page to a friend!

      PHP Forms Class with HTML Generator and JavaScript Validation  >  PHP Forms Class with HTML Generator and JavaScript Validation package blog  >  How to Show Google Ma...  >  All threads  >  AJAX validation update  >  (Un) Subscribe thread alerts  
Subject:AJAX validation update
Summary:Possible to have your class update the Javascript and server
Messages:8
Author:Nikos
Date:2008-07-12 13:37:45
Update:2008-08-18 04:54:14
 

  1. AJAX validation update   Reply   Report abuse  
Picture of Nikos Nikos - 2008-07-12 13:37:45
Say you have a page where users can add comments and there is a button that says add extra comment that renders an extra comment input field by JavaScript so that when the form is submitted all the comments will be submitted.

Since the extra inputs are generated on the client side would it be possible to have your class update the JavaScript and server side validation for the form using AJAX for example?

Also I can't get emails when some replies to my posts.

  2. Re: AJAX validation update   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2008-07-12 17:54:33 - In reply to message 1 from Nikos
Currently generating inputs dynamically via Javascript is not possible but I have plans to do it. I just have not figured a good solution to implement that. I am open to suggestions.

As for server side validation of extra inputs, if you have a condition in your PHP script that checks something that determines that a dynamic input was added on the browser side, you can add that input on the server side and validate it when the form is submit via AJAX or not.

  3. Re: AJAX validation update   Reply   Report abuse  
Picture of Nikos Nikos - 2008-07-14 07:38:37 - In reply to message 2 from Manuel Lemos
--Currently generating inputs dynamically via Javascript is not possible but --I have plans to do it. I just have not figured a good solution to --implement that. I am open to suggestions.

Generating inputs dynamically via Javascript is a rare occurrence, only needed in the most complicated of situations. The difficulty would be to get your class to generate the necessary Javascript so that when extra inputs are generated they are validated by Javascript to. You would have to create a new type of input in your class that does this I think. I think this would be much easier if the new inputs were a twin (same name) of some other input in the form.








--As for server side validation of extra inputs, if you have a condition --in your PHP script that checks something that determines that a dynamic --input was added on the browser side, you can add that input on the --server side and validate it when the form is submit via AJAX or not.

Again this would be easier if the inputs were of the same name and then the length of the post array for that name could be used in the validation, probably by my custome code in the

if(doit){
}

part of your code.

  4. Re: AJAX validation update   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2008-07-16 02:08:04 - In reply to message 3 from Nikos
Right, but I am not thinking about the implementation. What I am concerned is how the API would work to make support for dynamically added inputs easy to understand for developers and easy configure without loosing flexibility.

I need to think more about this but I am very interested to add support for dynamically added inputs as I have the need for my own applications too.

Just let me know if you would more ideas how you would like to see it working from the developers point of view.

  5. Re: AJAX validation update   Reply   Report abuse  
Picture of Nikos Nikos - 2008-07-19 11:45:38 - In reply to message 4 from Manuel Lemos
We'll as much as possible I would like it to be defined as a custom input with some parameters that would let me control how it would be controlled and outputted in the html form. It would be useful to define as one of the custom input parameters an id of a button that would call the extra input to be outputted.

  6. Re: AJAX validation update   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2008-07-19 20:44:04 - In reply to message 5 from Nikos
I see. I am thinking about it.

As a draft for the concept I envision a new custom input that will act as a manager for one or more dynamically added inputs. It will take care of adding the dynamic inputs HTML as well any Javascript that needs to be executed to validate the newly added inputs.

I have not all figured out, so I need to give it more thought. Things that I have not sorted is how to add dynamic inputs when certain values need to be changed at browser run-time.

This is something that must be designed from the start. Maybe I need to write a proposal draft RFC document so everybody can comment and I can see if it addresses all the needs.

  7. Re: AJAX validation update   Reply   Report abuse  
Picture of Nikos Nikos - 2008-08-05 22:42:51 - In reply to message 6 from Manuel Lemos
Good luck my friend. If you pull this off I'm sure your will gain great applause.

  8. Re: AJAX validation update   Reply   Report abuse  
Picture of Form Class Form Class - 2008-08-18 04:54:14 - In reply to message 6 from Manuel Lemos
If we add a manager input for EACH kind of input that could be added at client side dynamically, the manager inputs should be able to take care of validations for their kind of dynamic inputs added on the client side. For instance:

Product
Size
Quantity
UnitPrice (server-side input)

The above manager inputs would have validation behaviors and should be able to validate any of their kind of inputs added on the client-side.

Hope that helps...