We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

changing maxvalue of numerictextbox dynamically or changing the maxvalue of numerictextbox from Javascript using razor.

Hi,
 
How can I change the maxvalue of numerictextbox's value from javascript, when we select something from dropdown list.
 
Thanks in advance
 

2 Replies

DE Devendar February 21, 2013 05:04 PM UTC

Hi.
 
How we can set empty value to numerictextbox from javascript.
 
Thanks in advance.


ME Meena Syncfusion Team February 22, 2013 11:14 AM UTC

Hi Devendar,

 

Thanks for contacting Syncfusion forums.

 

Query1: How can I change the maxvalue of numerictextbox's value from javascript, when we select something from dropdown list.

 

Your requirement of setting the max value to the NumericTextbox control based on any value in a dropdown can be achieved using  “obj._maxValue” method (where obj is the client object of numeric text box control). Please refer the below code snippet,

 

<code>

[View]

@Html.DropDownList("dropdown")

 

@Html.Syncfusion().NumericTextBox("num").Value(40)

 

[Script]

 

$(document).ready(function () {

        $("#dropdown").bind('change', function () {

            var obj = $find("num");

 

            var selectedVal = $("#dropdown").val();

            obj._maxValue = parseInt(selectedVal);

          

        });

    });

 

 

</code>

 

Query2: How we can set empty value to numerictextbox from javascript.

 

Currently we do not have support for setting null/empty values directly in Editors package. We have already logged a feature request report for this requirement in our database, we will implement this feature in our upcoming release Vol2, 2013, which will be rolled out by May, 2013. As for now, we have made a workaround solution for this requirement, please refer the below code snippet,

 

<code>

    function setval() {

        $(".sfInputText").val("");           //$("#num_numerictextbox") can also be used, where "num" is the control ID

    }

 

</code>

 

We have also prepared a simple sample with the above requirements and it can be downloaded from the below link.

 

Kindly have a look at the sample and let us know if it helps.

 

Please let us know if you have any other concerns.

 

Regards,

Meena



SyncfusionMVCApplication_8d9aba6.zip

Loader.
Live Chat Icon For mobile
Up arrow icon