Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9147381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:58:28+00:00 2026-06-17T10:58:28+00:00

I have a form, generated through rails helpers, that has some AngularJS on it.

  • 0

I have a form, generated through rails helpers, that has some AngularJS on it.

 = form_for some_models do |f|
      %fieldset.form-horizontal
          %div.some-class
     #And so on and so forth
      =f.submit

And so on.
Within this form, I have various angular directives and controllers nesting within each other. One of the directives is listening on a field and comparing its value to do some custom angular validation like so:

    ctrl.$setValidity("decisionRuleCodeActivated", scope.valid).

This sets ng-invalid/ng-valid on the form and the relevant fields correctly, however the forms submission can still occur with no problems.

While I understand that the “correct” way to block this behaviour is to introduce an ngSubmit, which does the validation, and then reaches out to an Angular Service which serializes to JSON and Posts to the relevant endpoint, this would require rewriting a truly obscene amount of code.

Thus my question:

How can I prevent the form from submitting, without doing so?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T10:58:29+00:00Added an answer on June 17, 2026 at 10:58 am

    My solution:

      if scope.valid is true
        angular.element("form.ng-valid").find("input:submit").click(->
          true
        )
      else
        angular.element("form.ng-invalid.ng-dirty").find("input:submit").click(->
          false
        )
    

    The code above in a method triggered by the a watch, just after the $setValidity in a directive

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form that has many dynamically generated checkboxes. At runtime, how can
I have a form representing a survey that is dynamically generated based on some
I'd like to have any Form managed through the StateMachine generated from LWUIT's 1.5
I have a form with some generated input fields like theese: <input value=March name=month[March]
I have been given some generated code which looks like so: <form id=form1 method=post
So I have a Rails application that upon user submission should generate some kind
I have a PHP-generated form that is used as an invoicing interface. Users work
I have a small form that is generated from a mysqli->query and I've set
I have a form that posts data through JQuery to a Controller that then
How can I generate form fields for a has_many :through association that has additional

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.