I have a form which has three blocks face-book, twitter and pinterest. I added a condition to allow submitting the form only when one of the block is selected. For that I did:
if ($("#fb").prop("checked") || $("#tw").prop("checked")||
$("#pin").prop("checked")) {
...
...
}
if ($("#fb").prop("checked") || $("#tw").prop("checked")||
$("#pin").prop("checked")) {
...
...
}
Now I want to add another condition where it will check inside the twitter block to check if the text field has less than 140 characters. For that I added an and condition
if ($("#fb").prop("checked") || $("#tw").prop("checked") && $(#"tw_text").val().length <= 140||
$("#pin").prop("checked")) {
...
...
}
But this has some faults like if the facebook is selected and tw_text has more than 140 characters then also the form gets submitted.
Please guide me to the correct way to add conditions to prevent submitting the form.