I have created one form with dynamically created check box\'s . And i have used one j query script that will check weather user has checked at-least one check box or not .Tf it
If you are going to return false from an event handler function, then you need to do it from the event hander itself, and not just another function that it calls.
Your onclick function doesn't have a return statement. It calls Validate
and then does nothing with the value that function returns.
onclick="return Validate();"
Convention reserves variable names starting with capital letters for constructor functions. Call your function validate
, not Validate
.
It is generally a better idea to handle this kind of test when the form is submitted rather than when a particular submit button is clicked.
Modern JavaScript doesn't use onclick
/onsubmit
/etc attributes. We use addEventListener instead.
function validate(event) {
// Your logic
if (someCondition) {
// Stop
event.preventDefault();
}
}
document.querySelector("form").addEventListener('submit', validate);