On Mon, 2009-03-02 at 16:12 -0800, zweb wrote: > I have two html forms on a page. Each html form has a django form > associated. > One form has validations. > When I submit the form (form1) which does not have validations, it > submit the other form (form2) on page as well and triggers the > validation on the form2.
If the forms are in different HTML "form" elements that should not be happening. The submit process only submits the current form element. > I do not want the form2 to validate on form1 > submit. How to achieve that ? If both forms are posting to the same Django view, you will need a way to tell them apart before constructing the form instances. Perhaps a hidden form field that you can check. Alternatively, the forms can submit to different URLs. They could be entirely different URLS ("location1/" and "location2/") or you could differentiate by using a query parameter ("location1?form=1" and "location1?form=2"). Which version is appropriate depends on the information flow through your site and the URL structure. I'd probably go with the first option, as a first cut, though. A little hidden field containing the form number that you can test: form_type = request.POST["form_type"] if form_type == "1": # Process the first form elif form_type == "2": # Process the second form else: # Somebody's messing with the form. Fail! > > I am doing form submit in javascript like this > > document.getElementById("id_project").onchange = submitForm; > > function submitForm(){ > document.form1.action='pages url'; > document.form1.submit(); > } As a debugging hint: first get it working without Javascript -- using plain old, ordinary submit buttons. Then, if problems occur when you introduce the Javascript you'll know that it's only because of the Javascript, not due to anything else. Malcolm --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---