Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
40
Java script with custom validation
posted

I have a webtextbox and webdropdown controls on a page and when I set a text value in the controls using javascript the custom validation see a empty controls as empty.

This is the java code I'm using

 google.maps.event.addDomListener(window, 'load', function () {
             var places = new google.maps.places.Autocomplete(document.getElementById('TextBox1'));
             google.maps.event.addListener(places, 'place_changed', function () {
                 var place = places.getPlace();
                 var address = place.formatted_address;
                 var latitude = place.geometry.location.lat();
                 var longitude = place.geometry.location.lng();
                 var mesg = "Address: " + address;
                 var addsplit = address.split(",");
                 var StatCity = addsplit[2];
                 var City = addsplit[1].trim();
                 var address = addsplit[0];
                 var Zip = addsplit[2].substring(4, 10).trim();

                 mesg += "\nLatitude: " + latitude;
                 mesg += "\nLongitude: " + longitude;
                 mesg += "\nAddess: " + addsplit[0];
                 mesg += "\nCity: " + addsplit[1];
                 mesg += "\nState: " + StatCity.substring(0,3);
                 mesg += "\nZip 3: " + addsplit[2].substring(4, 10);
                 alert(mesg);
                 var citytext = document.getElementById('PropertyCity');
                 citytext.value = City;
                 var index = 22
                 var Addresstext = document.getElementById('PropertyAddress');
                 Addresstext.value = address;

                 var zipcode = document.getElementById('PropertyZip');
                 zipcode.value = Zip;


                 var Statetext = $find('<%=PropertyState.ClientID%>');
                 var item = "Test"
                 
                 for (var i = 0; i < Statetext.get_items().getLenght() ; i++) {
                     alert(item);
                     item = Statetext.getItems().getitem(i).get_text();
                     alert(item);
                     if (item == addsplit[2].substring(0, 3).trim()) {
                         Statetext.get_items().getItem(i).select();
                     }
                 }
                 alert(item);

What am I doing wrong?

Parents
No Data
Reply
  • 10685
    Offline posted

    Hello Jeff, 

    I expect you mean “custom validation see non empty controls as empty”.

    What is more I assume you are using WebTextEditor and WebDropDown. 

    Can you elaborate a bit more on what you are trying to achieve? What is the exact issue? How are you setting the text value?

    Usually, if you select an item, the input value should get updated automatically.

     

    From what I see, you are doing the selection on the client it as expected.

    dropDown.get_items().getItem(i).select();

     

    In order to set the current text in the dropdown on the client-side you can do the following:

    var dropDown = $find('<%= WebDropDown1.ClientID %>');

    dropDown.set_currentValue('some value in the input', true);

     

    Can you attach a sample that reproduces the issue, so I can actually debug it?

    I am looking forward more feedback from you.

Children
No Data