At the present time, when a button which is an ajax submit is clicked,
control is transferred to the JavaScript that checks for correctly
populated required fields. If there is a required field that is not
correctly populated, an alert box is displayed. When the alert box is
closed, the ajax request proceeds with incorrect data. I want the ajax
http request aborted if the JavaScript finds a problem with the data.
Peter -
On Nov 30, 3:52 pm, "Christopher E. Franklin, Sr."
<[EMAIL PROTECTED]> wrote:
> Why don't you do the validation on the same page using javascript if
> you're going that route. Otherwise, you will have to use the model
> validation and let the controller method complete what it needs to.
> if($this->Model->create($this->data) && $this->Model->validates()) {
> if($this->Model->save($this->data)) {
> $this->redirect('/somewhere');
> exit;
> } else {
> throw new Exception("Could not save the user data!");
> }} else {
>
> $this->render();
> exit;
>
> }
>
> On Nov 30, 3:45 pm, peterhf <[EMAIL PROTECTED]> wrote:
>
> > How does one execute a JS script before the html request is made and
> > halt the request based on some condition in the JS? For instance, I
> > wish to check that required fields are correctly populated; if any
> > required field is not correctly populated, I want to show an alert and
> > return to the page without completing the http request. I am using the
> > 'before' option in the submit but have not discovered how to stop the
> > request from completing.
>
> > Thanks in advance for your suggestions.
>
> > Peter -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---