Jump to content

Prevent onclick if input is empty


Recommended Posts

Hi folks, 
I need an help. I have this button:

<form ... >
    <textarea ...></textarea>
    <button onclick="ajaxCart.add(product_id=3, attribute_id=13, true, null, quantity=1, null, stop);" type="submit" name="mymod_pc_submit_codice" class="button btn btn-default button-medium">
         <span>Aggiungi<i class="icon-chevron-right right"></i></span>


It allows me to: 
1 - submit a form (with a textarea field)
2 - call the ajaxCart.add function when user click the button.

So I have one button for 2 "actions". My problem is: how can I stop the onclick function if the input is empty?! I can stop the submit just adding "required" on the textarea tag. But how can I do with the ajaxCart.add function?!
Edited by files___ (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...