Permalink
Browse files

adicionando validacao para numero a e b

  • Loading branch information...
1 parent a547500 commit 78e55d291c692c30f90f08ee59bfbf49ce6951a0 @ti24horas ti24horas committed Oct 3, 2012
Showing with 9 additions and 1 deletion.
  1. +9 −1 calculator.js
View
@@ -1,6 +1,14 @@
$("#calcular").click(function() {
var resultado;
-
+ regvalidation = /^[\d]+$/;
+ if (!regvalidation.test($("#num-a").text())){
+ alert('numero a invalido');
+ return false;
+ }
+ if (!regvalidation.test($("#num-b").text())){
+ alert ('numero b invalido');
+ return false;
+ }
var numA = parseInt($("#num-a").val());
var numB = parseInt($("#num-b").val());

0 comments on commit 78e55d2

Please sign in to comment.