andrescabana86
andrescabana86

Reputation: 1788

knockoutjs validate multiple forms

i have three forms in my web

<form data-bind="submit: validForm" action="/adminNewProduct" method="post" enctype="multipart/form-data">
    // fields
    <input type="submit" value="Add">
</form>

<form data-bind="submit: validForm" action="/adminNewUser" method="post" enctype="multipart/form-data">
    // fields
    <input type="submit" value="Add">
</form>

<form data-bind="submit: validForm" action="/adminNewCategory" method="post" enctype="multipart/form-data">
    // fields
    <input type="submit" value="Add">
</form>

how can i valid only the used form, for example, the user wants to add a new category, so he add the fields on the form #adminNewCategory, and submit, so i need to check only that form and no the others

tnx

Upvotes: 0

Views: 310

Answers (1)

Brian S
Brian S

Reputation: 1061

instead of using the function validForm for all 3 forms, why not use 3 separate functions (ex. validNewProductForm, validNewUserForm, validNewCategoryForm)

Upvotes: 1

Related Questions