<html>
<head>
</head>
<body>
<textarea id=txt></textarea>
<button id="check_txt">check_txt</button>
<button id="check_var">check_var</button>
<button id="reset">reset</button>
<script>
myvar=0
check_txt.onclick=function(){
if(/\d/.test(txt.value)) myvar=1
}
check_var.onclick=function(){alert(myvar)}
reset.onclick=function(){myvar=0}
</script>
</body>
</html>