- Home
- Forum
- ASP.NET Web Forms
- Autocomlete + JQuery validation
Autocomlete + JQuery validation
I have some Autocomplete fields, bound to a DataManager. When I set ValidationRules and ValidationMessages and there is a Validation Error, the error message does not disappear when I programmatically fill the field.

<ej:Autocomplete ID="txtShipName" runat="server" Width="350px" Height="40px" DataTextField="Name" DataUniqueKeyField="AddressID" Locale="nl-BE" FilterType="Contains" EnableDistinct="true" WatermarkText="To: Address Book Search" PopupWidth="600px" Query="ej.Query().requiresCount()" ShowEmptyResultText="False">
<DataManager URL="NewOrder.aspx/GetAddressbook" Adaptor="WebMethodAdaptor"></DataManager>
<MultiColumnSettings Enable="true" ShowHeader="true" StringFormat="{0}">
<Columns>
<ej:Columns Field="Name" HeaderText="Name" FilterType="Contains" />
<ej:Columns Field="City" HeaderText="City" FilterType="Contains" />
<ej:Columns Field="Street" HeaderText="Street" FilterType="Contains" />
</Columns>
</MultiColumnSettings>
<ValidationRule>
<ej:KeyValue Key="required" Value="true"></ej:KeyValue>
</ValidationRule>
<ValidationMessage>
<ej:KeyValue Key="required" Value="*Name Required*"></ej:KeyValue>
</ValidationMessage>
</ej:Autocomplete>
-> fill in field from Google API with listener on changed event
acShip = new google.maps.places.Autocomplete(document.getElementById('<%=txtShipGoogle.ClientID %>'), { region: 'EU' });
acShip.onFocus = geolocate(acShip);
acShip.addListener('place_changed', fillInShipAddress);
fillInShipAddress:
if (place.name) {
$('#<%=txtShipName.ClientID %>').ejAutocomplete({ value: place.name.toUpperCase() });
};
-> validator defaults
$.validator.setDefaults({
//Ignore input of numerictextbox
ignore: ".e-numerictextbox",
//if we don’t set custom class, default “error” class will be added
errorClass: 'e-validation-error',
//it specifies the error message display position
errorPlacement: function (error, element) {
$(error).insertAfter(element.closest(".e-widget"));
}
});
-> validation message does not disappear when text is entered programmatically
SIGN IN To post a reply.
3 Replies
1 reply marked as answer
MK
Muthukrishnan Kandasamy
Syncfusion Team
November 2, 2020 10:18 AM UTC
Hi Peter,
Thanks for contacting Syncfusion support.
We have validated your reported problem in EJ Autocomplete control with JQuery validation. But we were unable to reproduce your reported problem in our end, the JQuery validation works properly even when changing the value, programmatically. We have prepared sample for your convenience, please refer to the below link for the sample.
|
Description |
Link |
|
Getting started |
|
|
How-to section |
|
|
API reference |
|
|
Live demo |
If the issue still persists, please share some additional details. It will be help us to provide you the prompt solution.
- Share us the issue replicating sample or else replicate your reported issue in the shared sample.
- If you face any script error in console window of the browser, then please share us those error screenshots.
- Share us the screen recorded video with issue replicating steps.
Regards,
Muthukrishnan K
Marked as answer
PE
Peter
November 2, 2020 08:54 PM UTC
Dear,

thanks for the sample. I can replicate the issue in your sample, if you add a Google Maps autocomplete field and a listener to fill in the selected Google Address into the Syncfusion Autocomplete. So if you first click Submit, you get the validation error. If you then search Google and select an address, the autocomplete field gets filled in, but the validation error remains:
Please update your sample with the items in bold:
PS I have replaced my Google Maps API key with *****
<button onclick="valuechange()">change value</button>
<button type="submit" runat="server">Submit</button>
<asp:TextBox ID="txtShipGoogle" runat="server" Width="300px" Height="40px" CssClass="form-control" placeholder="Google Search" />
<ej:Autocomplete ID="autoComplete" runat="server" Width="300px" DataTextField="Name" ShowPopupButton="true" DataUniqueKeyField="Role" Query="ej.Query().requiresCount()">
<datamanager url="Default.aspx/Get" adaptor="WebMethodAdaptor" />
<multicolumnsettings enable="true" showheader="true" stringformat="{0}">
<Columns>
<ej:Columns Field="Name" HeaderText="Name" FilterType="Contains" />
<ej:Columns Field="Role" HeaderText="Role" FilterType="Contains" />
<ej:Columns Field="Street" HeaderText="Street" FilterType="Contains" />
</Columns>
</multicolumnsettings>
<validationrule>
<ej:KeyValue Key="required" Value="true"></ej:KeyValue>
</validationrule>
<validationmessage>
<ej:KeyValue Key="required" Value="*Name Required*"></ej:KeyValue>
</validationmessage>
</ej:Autocomplete>
<script>
$.validator.setDefaults({
//if we don’t set custom class, default “error” class will be added
errorClass: 'e-validation-error',
//it specifies the error message display position
errorPlacement: function (error, element) {
$(error).insertAfter(element.closest(".e-widget"));
}
});
function valuechange(args) {
$('#<%=autoComplete.ClientID %>').ejAutocomplete({ value: "Test" });
}
function init() {
acShip = new google.maps.places.Autocomplete(document.getElementById('<%=txtShipGoogle.ClientID %>'), { region: 'EU' });
acShip.addListener('place_changed', fillInShipAddress);
};
function fillInShipAddress() {
var place = acShip.getPlace();
if (place) {
if (place.name) {
$('#<%=autoComplete.ClientID %>').ejAutocomplete({ value: place.name.toUpperCase() });
document.getElementById('<%=txtShipGoogle.ClientID %>').value = "";
};
};
};
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=*****&libraries=places&callback=init" async="async" defer="defer"></script>
MK
Muthukrishnan Kandasamy
Syncfusion Team
November 3, 2020 01:28 PM UTC
Hi Peter,
Thanks for the update.
We were unable to reproduce the reported problem with your provided details. As requested as earlier, please share some additional details. It will be help us to provide you the prompt solution.
- Whether the reported issue only occurs with google maps service or it occurs when dynamically updating the Autocomplete value ?
- Share us the issue replicating sample or else replicate your reported issue in the shared sample.
- If you face any script error in console window of the browser, then please share us those error screenshots.
- Share us the screen recorded video with issue replicating steps.
Regards,
Muthukrishnan K
SIGN IN To post a reply.