0

I am currently doing a project which was last worked on a couple of years ago. As there has been no knowledge transfer to me, it's all kind of convoluted for me.

The app uses AngularJS. I have a bootstrap pager, which has a Jump to page: [ ] field. Currently, that field accepts both integers and decimals, and I obviously don't want decimal page numbers.

I know I could try to find somewhere in JS to validate the input, but I'm looking for a way to validate input inside html - more precisely, to check if some input is integer.

My HTML element is:

<div style="float:right;margin-right:10px;">
<span style="float:right">Jump to page:</span>
<br/>
<div class="col-xs-5" style="float:right">
    <input class="form-control" id="navPageField" type="text"
           ng-model="pager.pageToNavigate"
           snp-enter="pager.navigateToPage(pager.pageToNavigate)"
           tooltip="page {{pager.currentPage}} / {{pager.pageCount}}"
           tooltip-trigger tooltip-animation="true" tooltip-placement="bottom" />
</div>

EDIT: Solved it by adding pattern="^[0-9]*$" to the input element. type=number did not work as expected for me, even when adding step="1".

Ivan Kukic
  • 425
  • 4
  • 14

0 Answers0