I would like to compare user input with predefined value on same jsp page. If the input value is same as expected, then i allow user go ahead to submit the request form. But i don't know how set the predefined value for checking. Thanks.
<tr><td>Application</td></tr>
<% 
String strDBCode = "123456789";
out.println("<tr><td><b>Please input your pass code here:</b></td></tr>");
out.println("<tr><td><input type='text' name='strPassCode' value=''></td></tr>");
out.println("<tr><td><input type='hidden' name=strDBPassCode size='15' maxlength='15' value=strDBCode id='b'></td></tr>");
out.println("<tr><td><input type='button' name='chkPassCode' value=' Check ' onClick='return chkPCode()'></td></tr>");
%>
<script type="text/javascript">
function chkPCode()
{
    var a = document.getElementById("a");
    var b = document.getElementById("b");
    var valid = true;
    if (a.value !=  b.value) {
        alert("Not Match!");
        valid = false;
    }
    else {
        alert("Match");
        valid = true;
    }
    return valid;
}
</script>
I expect b value should be "123456789", but b always equal to "strDBPassCode". I have try set out.println(" id='b'>"); It return error. Since the input already inside <% %>.
Apart from that, how to disable the input text box if valid return is true?
Any idea? thanks.
 
    