Jeanne Boyarsky wrote:It works on my computer when I reconstructed your example. (I had to add parens after the function and the text field.)
This is what I ran. It's possible your code has more in it and something else broke it. Have you looked at the JavaScript error console to see if there are any details? Or comment out extra code to see when the error goes away?
Thanks a lot Jeanne. I have just basic knowledge of Javascript and I don't really know what a JavaScript error console is... or how one sees it... I used the same kind of coding in a .HTML file, and it worked for me, but this coding is from a .JSP file and it doesn't work as intended.
The error only goes away when I remove the condition to ensure only numbers are entered, i.e if I leave the "amount" text box empty, I am prompted that it is empty, and it doesn't redirect me to the page specified in the form action.
by the way, I tried a different approach, <input type="number"> and it worked for me on Google Chrome but it won't work for me on MyEclipse browser. I think this might have something to do with HTML5 (isn't number type supposed to be for HTML5?) not working on some browsers? I honestly have no idea, thank you a lot.