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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Reset angular numeric TextBox to default value on invalid content

Thread ID:

Created:

Updated:

Platform:

Replies:

119391 Jun 15,2015 12:17 PM UTC Jun 17,2015 03:54 AM UTC JavaScript 1
loading
Tags: General
Robert David
Asked On June 15, 2015 12:17 PM UTC

Hi I am trying to reset a numeric textbox back to the original value when invalid input is detected (deleting all the contents of the field causes the field to remain empty instead of reverting back to the default)
The main problem is that it is not re-rendering when the $scope.intervallength value changes is there a way of resetting the textbox when the contents are not a number?


    <input id="IntervalLengthSpinner" type="text" ej-numerictextbox e-value="intervalLength" e-focusout="focusOut" e-minvalue="1" e-maxvalue="10000" />

Inside the controller I am using the following:


   $scope.intervalLength = 1;

            $scope.focusOut = function (args) {
                if (!angular.isNumber(args.value)) {

                  console.log("invalid entered");
                   $scope.$apply(function () {
                        $scope.intervalLength = 1;
                    });
                
                    //$scope.intervalLength = 1;
                    // var y = $("#" + args.model.name + "~ .e-select").find(".e-spin.e-spin-up");
                    //   y[0].click();
                    //var u = y.find(".e-spin.e-spin-up");
                    //$("#" + args.model.name[0]).find("e-spin e-spin-up")[0].click();
                    //var t = $("#" + args.model.name);
                    //$scope.$apply(function() {
                    //    $("#" + args.model.name).prop({ "aria-valuenow": 1 });
                    //});
                   //args.value=$scope.intervalLength;

                    // $scope.$apply();
                }
                else {
                    $scope.intervalLength = args.value;
                    console.log("valid");
                    console.log($scope.intervalLength);
                }
            };

Sasikala Nagarajan [Syncfusion]
Replied On June 17, 2015 03:54 AM UTC

Hi Robert,

Thanks for using Syncfusion products,

We have analyzed your query. We have prepared the simple sample based on your requirement.

Please get the sample from below location

Sample

In this sample, in numeric text box change event, we have validated the numeric text box value and sets to default the value to textboxif the numeric text box value is not a number.

Please refer the below code snippet

$scope.valueChange = function(args) {

if (!angular.isNumber(args.value))

{

s=$("#numeric").ejNumericTextbox('instance');


$scope.$apply($scope.nvalue=""); // bind the value to empty before bind the same value to model.

$scope.$apply($scope.nvalue=1);

}

}



Please check with given sample andlet us know if you further quieries,

Regards,

Sasikala Nagarajan


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;