Skip to content

Commit

Permalink
week 12 : InPlaceCalculator with js validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Dierk Koenig committed Dec 13, 2019
1 parent 1ecd023 commit 3cd1a8a
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions grails-app/views/inPlaceCalculator/calc.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
<title>
In-Place Calculator
</title>
%{-- todo: 3 add on-page validation--}%
%{-- <script>--}%
%{-- function validate(field) {--}%
%{-- if( Number(field.value) < 1.0) {--}%
%{-- field.classList.add("error");--}%
%{-- field.focus();--}%
%{-- } else {--}%
%{-- field.classList.remove("error");--}%
%{-- }--}%
%{-- }--}%
%{-- </script>--}%

<script>
function validate(field) {
if( Number(field.value) < 1.0) {
field.classList.add("error");
field.focus();
} else {
field.classList.remove("error");
}
}
</script>
</head>

<body>
Expand Down

0 comments on commit 3cd1a8a

Please sign in to comment.