문제

I'm trying to submit a specific form Using the following command:

$("#formName").submit();

Definitely that's working, but, I have required fields into the form, and if those're empties it's not throwing the alert message. Any ideas around that?

도움이 되었습니까?

해결책

Surround your $("#formName").submit(); in an if statement that checks the (length of) the values in your required fields, that way the form will only submit if those values are present.

You could go one step up and use separate methods for validation that return a boolean, and only if all validation methods return true do you submit the form.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top