Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Form submits only with button click? Not on <enter> within a field. Also ng-submit #247

Closed
chorsnell opened this issue Oct 14, 2016 · 3 comments

Comments

@chorsnell
Copy link
Contributor

So there seem to be a few issues submitting forms.

I can only attach the submit to an ng-click on a button, and when I press enter it doesn't get caught.

Ideally I want to use ng-submit to declare the function that should be fired, and able to submit via enter OR pressing the submit button. Both ways of submitting should be blocked by the validation.

https://plnkr.co/edit/nwTEuxuTMmpEc4hrFwGp?p=preview

Without entering anything, you can hit enter, and the submitYo function is fired regardless of validation status.

Also when ensuring the form validates, hitting the button will only run the click event, not the one specified on form submit.

Any ideas?

@hueitan
Copy link
Owner

hueitan commented Oct 20, 2016

What you can do is updating the button type to type=button
I would suggest putting all the function in ng-click instead of using ng-submit

I don't combine the angular-validation logic with ng-submit yet,

@chorsnell
Copy link
Contributor Author

Thanks for the response. And ng-submit is coming at some point? :)

Yeah ended up doing that, but then put the function + valid check in ng-submit too, feels a bit hacky though but can't guarantee someone is going to actually 'click'

@hueitan
Copy link
Owner

hueitan commented Oct 20, 2016

nice, do you want to add your solution into Q&A section?

So that people can benefit from it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants