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

How i can get value in numeric textbox (ej:NumericTextBox) from JS?

Hi,
How can I alert the NumericTextBox value?

<ej:Dialog ID="Dialog199" Title="Sample" runat="server">
    <DialogContent>
        <div>
            <br />
            Your dialog contents here 
            <br />
            <ej:NumericTextBox runat="server" ID="num1" Value="3"></ej:NumericTextBox>
            <br />
            <ej:Button runat="server" ID="button1" Text="OK" ClientSideOnClick="btnOK"></ej:Button>
            <ej:Button runat="server" ID="button2" Text="Cancel"></ej:Button>
        </div>
    </DialogContent>
</ej:Dialog>


<script type="text/javascript">

    function btnOK() {

        var dialogObj = $("#<%=Dialog199.ClientID%>").data("ejDialog");
        dialogObj.close();

        var num1Obj = $("#<%=num1.ClientID%>").ejNumericTextBox("instance");
        alert(num1Obj.value()); ???
        
    }

</script>

Thanks,
   Tomer

1 Reply

KS Kaviyarasu Sivasenapathi Syncfusion Team August 4, 2017 12:44 PM UTC

Hi Tomer, 
Thanks for contacting Syncfusion support. 
We have analyzed your query (“Not able to get the numeric textbox value”). You can achieve your requirement by using getValue() method of “NumericTextbox” component. Please refer the below code block. 
[CSHTML] 
 
<div id="ControlRegion"> 
    <div class="control"> 
        @{Html.EJ().Dialog("basicDialog").Title("Dialog").Width("550px").Height("200px").ContentTemplate(@<div> 
 
            @Html.EJ().NumericTextbox("numeric").Value(35).Width("400px") 
 
            @Html.EJ().Button("ok").Text("OK").ClientSideEvents(evt => evt.Click("btnOK")).Width("70px").Height("30px") 
 
            @Html.EJ().Button("cancel").Text("CANCEL").Width("70px").Height("30px") 
 
        </div>).Render();} 
    </div> 
</div> 
 
[script] 
 
<script> 
    function btnOK(args) { 
        var dialogObj = $("#basicDialog").data("ejDialog"); 
        dialogObj.close(); 
        var num1Obj = $("#numeric").data("ejNumericTextbox"); 
        alert("current value is: " + num1Obj.getValue()); 
    } 
</script> 
 
For your convenience, we have attached the sample below.  
To know more details about getValue() method, please refer the following documentation link  
Please let us know if you need further assistance on this. 
 
Regards, 
Kaviyarasu S   


Loader.
Up arrow icon