<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: How to switch off validation for ajax call?</title><link>https://answers.axonivy.com/questions/4271/how-to-switch-off-validation-for-ajax-call</link><description>&lt;p&gt;Hi Ivy Team&lt;/p&gt;
&lt;p&gt;I have a autocomplete. The autocomplete is required field. In autocomplete. I have ajax to handle change event. When autocomplete changes, some fields will be updated below. But When I clear data from autocomplete. The message required is display and some fields are no more update. So I want to do validation only when a button is clicked which submits the form but not when autocomplete changes. How I can do this?&lt;/p&gt;
&lt;p&gt;Note: I try using "immediate" attribute in ajax to switch off validation but it is not work.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;p:autoComplete id="select-vendor" 
                widgetVar="select-vendor"
                value="#{purchase.vendor}" 
                dropdown="true" 
                scrollHeight="400"
                completeMethod="#{tenderInformationBean.completeVendor}"
                var="vendor" 
                itemLabel="#{vendor.vendorName}" 
                itemValue="#{vendor}" 
                maxlength="50"
                converter="pojoConverter" 
                cache="true" 
                queryDelay="500"
                rendered="#{!tenderInformationBean.isVendorNotFound}" 
                binding="#{tenderInformationBean.vendorNameAutoComplete}"
                disabled="#{isReadOnlySupplier}" 
                forceSelection="true"
                requiredMessage="#{ivy.cms.co('/ch.ivy.addon.portalkit.ui.jsf/common/requiredFieldMessage')}" &amp;gt;

                &amp;lt;p:ajax event="change" update="vendor-information-fieldset" global="false"
                    listener="#{tenderInformationBean.onSelectVendorName(purchase)}" onstart="if(PF('select-vendor').panel.is(':visible')) return false;"
                    immediate="true"/&amp;gt;

                &amp;lt;p:ajax event="itemSelect" update="vendor-information-fieldset" global="false"
                    listener="#{tenderInformationBean.onSelectVendorName(purchase)}" /&amp;gt;

                &amp;lt;f:validator validatorId="awsValidator" /&amp;gt;
            &amp;lt;/p:autoComplete&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Thanks&lt;/p&gt;</description><atom:link href="https://answers.axonivy.com/questions/4271/how-to-switch-off-validation-for-ajax-call" rel="self"></atom:link><language>en</language><lastBuildDate>Thu, 12 Dec 2019 03:05:20 -0500</lastBuildDate><item><title>Answer by Lukas Lieb</title><link>https://answers.axonivy.com/questions/4271/how-to-switch-off-validation-for-ajax-call/4273</link><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;In my opinion is immidiate="true" (as you said) the way to go. But you have two ajax elements and the immidiate is only set on the first. Additionaly the documentation from Primefaces mention no change event on autocomplete widgets (&lt;a href="https://primefaces.github.io/primefaces/8_0/#/components/autocomplete)."&gt;https://primefaces.github.io/primefaces/8_0/#/components/autocomplete).&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;I think you're problem is that you set this flag on the wrong ajax element. And if this still not working may you can try to add a process="@this" to the ajax element. &lt;/p&gt;
&lt;p&gt;PS: On google you can find a lot to Primefaces and JSF stuff too ;)&lt;/p&gt;
&lt;p&gt;Kind regards &lt;/p&gt;
&lt;p&gt;Lukas&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Lukas Lieb</dc:creator><pubDate>Thu, 12 Dec 2019 03:05:20 -0500</pubDate><guid>https://answers.axonivy.com/questions/4271/how-to-switch-off-validation-for-ajax-call/4273</guid></item></channel></rss>