I use LiveValidation plugin (http://livevalidation.com). I need validate one input and if it is ok, make same ajax. Instead submit button I have img and I would like to process it by onClick action. Everything works validation works live, but when I click on image I need to check if is email fill and valid. Is some method like isValid or how can I do it and avoid to process ajax always after click?
<input id="email" type="text" name="email" />
<img id="sendToEmail" src="send.png" />
<script type="text/javascript">
var email = new LiveValidation('email', { validMessage: ' ', wait: 500 } );
email.add( Validate.Presence, { failureMessage: "Is required" } );
email.add( Validate.Email, { failureMessage: "Must by email" } );
$('#sendToEmail').click(function() {
if (email.isvalid) {
//ajax calling
}
})
</script>
This is right solution
if (email.validate()) {
// some process if is validated
}
You can use: