Welcome Guest, Not a member yet? Register   Sign In
validate ajax populated form
#1

[eluser]xpix[/eluser]
Hi all,

I was wondering if someone has an idea on how to validate a form that is populated with an ajax request based on a select field.

More info:

my page is index.php/form

in this page I have a form and a select field. When you pick a value I get the rest of the form from index.php/fillform/rest_of_the_fields_no using jquery's ajax method.

so now my form is

select field
field 1
field 2
field 3
submit button

How do I validate the 3 new fields?


My controller is looks like this

function index(){
//prepare form.
}
function fillform($rest_of_the_fields_no){
//prepare rest of the form.
}

Thank You
#2

[eluser]Randy Casburn[/eluser]
How about sharing the action="" element of the <form> tag? Where are you post the form contents? And how are you posting them? With the click of a standard <input type='submit'> ?
#3

[eluser]xpix[/eluser]
the rest of the form is loaded between the form tags.

the problem is that if a field does not validate you go back to the same page and since a part of the form is loaded with ajax I need to set up the erors in the ajax controler in this case "fillform".

I'll do some more research.
#4

[eluser]Randy Casburn[/eluser]
Without providing more information you're making it difficult to help. Can't read your mind, but I'll take a stab at helping anyway.

Ordinarily your ajax requests simply call separate methods in your controller depending on what you need in your page.

fillform() -> fill out the rest of the form fields

validateform() -> validate the submission

senderror() -> return error notices back to form

etc.

All this stuff presumably would gather data from Models or send back information via JSON encoded strings that is simply echo directly from Models or your Controller.

Hope this helps.




Theme © iAndrew 2016 - Forum software by © MyBB