Count
Count

Reputation: 1423

input type number is returning null

On sumbit of the form to a ng-controller, I am getting null for the field named capital , in the controller defined below

<input id="capital" name="capital" pattern="(^\d+(\.|\,)\d{2})" type="number" min="0.00" step="0.01"     placeholder=""  required="" ng-model="capital">

However I am able to get correct data on my controller when I input decimal value in it

here is my controller

$scope.addCustomer=function(){
var data_to_send={};
    data_to_send.capital=$scope.capital;
    alert(data_to_send.capital);
}

In other words

when i try to alert the field capital in my ng-controller

10.10 alert prints 10.10 but for 10 it prints undefined

Upvotes: 1

Views: 949

Answers (1)

Oleksandr T.
Oleksandr T.

Reputation: 77482

Try change pattern to this

<input id="capital" name="capital" pattern="(^\d+(\.|\,\d{2})?)" type="number" min="0.00" step="0.01" placeholder="" required="" ng-model="capital">

Upvotes: 1

Related Questions