I use jQuery, but I am dealing with markup created in JSF pages. Many elements have onclick attributes provided by JSF code (which is not my area).
Example:
<div onclick="[jsf js to submit form and go to next page]">submit</div>
I am trying to add some client side validation using jQuery. I need something like this pseudocode:
$('div').click(function(e){
if(myValidation==true){
} else {
$error.show();
}
})
Is there any best practice for this?
It seemed to me that when loading the page, grab the value of the onclick attribute, remove the onclick attribute from the object, then ... well, where am I getting lost. I could cache JS as text in a data attribute, but I'm not sure how to do this later.
source
share