Sai

Sai

  • NA
  • 203
  • 30k

Validation for html controls

Aug 2 2017 6:40 AM
Hi,
 
I have a query ..
 
i have a text box[ taken for age]
 
  @Html.TextBox("Age", string.Empty, new { @class = "ControlWidth", ng_model = "age" , ng_keypress = "onlyNumbers($event)", type = "number", min=1 ,max=100 })
 
The above code display Spinner input control [type = "number"]
 
 if i don't give any input and click on save button, then the validation error message executed successfully.See below is my validation code
 
if ($scope.age == "" || $scope.age==null ) {
$scope.errormsg = "Please Enter Age";
return false;
}
  
 
but if i given more than 100 like 101 then my validation message is not working. see below code.
 
if ($scope.age <1 || $scope.age>100 ) {
$scope.errormsg = "Range is 1 to 100 only";
return false;
}
 
Please find the below attachment.
 
Thanks in advanced 
 
 

Attachment: AgeValidation.zip

Answers (2)