What you'd do in JavaScript, once the two boxes are generated.
If you remember to give each one an id, It should be simple enough:
<script type='text/javascript'>
var box1 = docuement.getElementById('box1').value;
var box2 = docuement.getElementById('box2').value;
if( Appropriate_String_Comparison(box1, box2) == 0) {
doSomething();
}
else
doSomethingElse();
</script>
This is using simple javaScript. No magic frameworks are needed.