You need to sign in to do that
Don't have an account?
Actionsupport onchange doesn't act
Hi, in a visualforcepage I want to start an action (in this case a usermessage) after a change in an inputfield. I have two problems with this:
- in Firefox I got the action to work, in IE8 it doesn't work.
- if the inputfield is a date field, the action only works (in firefox) if the change is made directly in the field, not if the date is picked from the date-picker (calendar). It seems as if the system doesn't see this as a field change.
Anyone who has an advise on this?
Apex (extension):
...
public pagereference controleerBSN(){
if (!leesobject.bsncheck(medewerker.burgerservicenummer__c)){ // checks wether ID is valid
ApexPages.Message bsnfout = new ApexPages.Message(ApexPages.Severity.ERROR, 'BurgerServiceNummer fout');
ApexPages.addMessage(bsnfout);
fieldcheckStyle = 'border-size:2px; border-color:red;border-style:solid;';
} else {
fieldcheckStyle = '';
}
return null;
}
...
Visualforce page:
...
<apex:pageBlock title="Medewerkergegevens" mode="edit" id="medewerkerblock">
<apex:PageMessages />
...
<apex:pageblockSectionItem >
<apex:outputLabel value="{!$ObjectType.Medewerker__c.fields.BurgerServiceNummer__c.label}" for="bsn"/>
<apex:outputpanel>
<apex:inputfield value="{!mdw.BurgerServiceNummer__c}" id="bsn" style="{!fieldcheckStyle}"/>
<apex:actionsupport event="onchange" action="{!controleerbsn}" rerender="medewerkerblock"/>
</apex:outputpanel>
</apex:pageblockSectionItem>
...
That's because onchange is only fired when a user changes the contents of a the HTML input component. When a datepicker is used, the user clicks on the datepicker value, which uses JavaScript to update the contents of the HTML input component.
I seem to remember that I added actionsupport for the onblur event rather than onchange. That way my action fired when the user navigated away from the date input field. I'm actually using another datepicker included as a static resource, as I ended up needing more control than the default one gives you.