Hi I have a form that use a js file to validate form fields. One of this fileld is a number that must be five multilple , but this error for even number that are five multiple such 55. This is my code: var myVariable = frm.withdraw.value / 5; if (myVariable != 0) { showError("Invalid amount") frm.withdraw.focus() frm.withdraw.select() return false } Code (markup): Where is problem??!
It can't work like that, you will get true for every number greater 4. For Example: myVar = 55 / 5; Result is 11, and 11 is != 0 Try this: var myVariable = parseInt(frm.withdraw.value) % 5; if (myVariable != 0) { showError("Invalid amount") frm.withdraw.focus() frm.withdraw.select() return false } Code (markup):