PHP on T R A X
Rapid Application Development Made Easy

Reply to topic
ajax form validation with observe_field()
gomez_uk


Joined: 27 Sep 2008
Posts: 6
Reply with quote
Hi, I'm trying to make an ajax form which automatically validates each input box when the contents are changed. I've looked at a rails method of doing this and can't make head nor tail of it.

I've been using observe field in my _form partial but nothing happens when i try and change some text in the input field. Here is the _form.phtml file I am refering to:

Code:
<?php echo error_messages_for("event") ?>

<? observe_field("event_name",
               array("url"=>array(":action"=>"validate"),
               "update"=>"event_name_msg"));   ?>


<!--[form:event]-->
<div id="form_wrapper">
   <table>
      <tr>
         <td><label for="event_name">Event Name:</label><?= text_field("event", "name") ?></td>
         <td><?= image_tag("loader.gif", array("id" => "loader1", "style" => "display:none")) ?> </td>
         <td><div id="event_name_msg">Please enter an event name.</div></td>
      </tr>
      <tr>
         <td><label for="event_artist_id">Artist:</label><?= collection_select("event", "artist_id", Artist::selectbox_collection(), "id", "name", array("include_blank" => true)) ?></td>
         <td><?= image_tag("loader.gif", array("id" => "loader2", "style" => "display:none")) ?> </td>
      </tr>
      <tr>
         <td><label for="event_datetime">When does it start?</label><?= datetime_select("event", "datetime", array("start_year" => 2008,"end_year" => (date('Y') + 2))) ?></td>
         <td><?= image_tag("loader.gif", array("id" => "loader3", "style" => "display:none")) ?> </td>
      </tr>
      <input type="hidden" name="event[user_id]" value="<?= $this->session->get('user_id') ?>">
   </table>
</div>
<!--[eoform:event]-->


Am I going about ajax form validation the right way? Any links to an example would be very much appreciated.
View user's profileSend private message
gomez_uk


Joined: 27 Sep 2008
Posts: 6
Reply with quote
anyone know anything about this? Or give me a hint?
View user's profileSend private message
ajax form validation with observe_field()
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 7 Hours  
Page 1 of 1  

  
  
 Reply to topic