Tips for checking a form without scrolling down in angularjs?

Trying to create a form validation for the 'Agree to Information' page. The user must scroll down to proceed, without a checkbox at the bottom of the box. If the user clicks continue/agree without scrolling, an error div element should display with the message 'Scrolling to the bottom of the information is required'. This message should be a clickable anchor link that highlights the box in color. See below for code and image:

 (function(){
    angular
        .module('agreeToInfoApp',[])
        .directive('execOnScrollOnBottom', [function () {
            return {
                restrict: 'A',
                link: function (scope, elem, attrs) {
                    var fn=scope.$eval(attrs.execOnScrollOnBottom),
                        clientHeight=elem[0].clientHeight;
                    elem.on('scroll',function(e){
                        var el=e.target;
                        if ((el.scrollHeight-el.scrollTop) === clientHeight) {
                            elem.addClass('class-summary')
                            scope.$apply(fn);
                        };
                    });
                }
            };
        }]);
})();

html:

<body>
<div class="class-summary">
    <div class="open">
        <p>Some Information Missing</p>
        <ul>
            <li>Please scroll down to lookup the information</li>
        </ul>
    </div>
</div>
<form name="myform" >
    <div cols="3" exec-on-scroll-on-bottom name="agreeTerms" class="agree-terms" >
        <p>adsfadfad</p>
        <p>adsfadfad</p>
        <p>adsfadfad</p>
        <p>adsfadfad</p>
        <p>adsfadfad</p>
        <p>adsfadfad</p>
        <p>adsfadfad</p>
        <p>adsfadfad</p>
        <p>adsfadfad</p>
        <p>adsfadfad</p>
        <p>adsfadfad</p>
        <p>adsfadfad</p>
    </div><br>
    <input type="submit" value="Continue" >
</form>
<script type="text/javascript" src="../../lib/angular.js"></script>
<script type="text/javascript" src="app.js"></script>

If there are any missing pieces or alternative solutions, please advise.

Agree To Information Page

Answer №1

A small adjustment is all that's needed to perfect your situation.

if (el.scrollTop === el.scrollHeight - el.offsetHeight) {
  // reached bottom of scroll
}

Check out this JSFiddle example: http://jsfiddle.net/9d6pb0/

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

"Utilizing the __proto__ property in Express.js for handling request

One issue that I've encountered is with the request.body generated by the express.urlencoded() middleware. Sometimes, it adds "__proto__" at the end of the request.body object, which makes it impossible to directly use it to initialize a mongoose mode ...

Comparing json results from ng-repeat against an array

Currently, I am working with a JSON result that appears in an ng-repeat and I want to filter it based on separate data objects or arrays: Controller.js $scope.jsonResult = [ { "id": "a123" }, { "id": "b456" } ] HTML <span ng-repeat="r in js ...

Error retrieving Facebook access token using Node.js https.get()

I've been working on setting up a Facebook login flow in my node.js app, but I'm facing an issue where the access token isn't returning from the Facebook API when using node's https.get() method. Interestingly, I am able to retrieve the ...

Guide to Binding a JSON Property (Set or Array) to an Interactive Input Form in AngularJS

My input form is structured like this: <div> <div class="form-group"> <label for="inputQuestion" class="col-sm-2 control-label">Question</label> <div class="col-sm-10"> <input data-ng-model="publication.qu ...

Repairing a syntax error in a jQuery selector variable

$(".className").click(function(){ var link = $(this).find("a").attr('href'); //output is '#myID' var findItems = $(link '.mydiv').length; //WRONG var findItems = $(link + '.mydiv').length; ...

Using the mouse scroll to activate the $anchorScroll effect in Angular instead of a click

I have been searching for a solution to my problem without any luck so far. Hopefully, someone here can provide guidance and help me find a solution. My goal is to replicate the behavior shown in the second example on the following page: https://docs.angu ...

The jquery live click event is not functioning properly on iPad devices

I am experiencing an issue with a webpage that has the following code to bind click events <script type="text/javascript"> $(".groupLbl").live("click", function(e) { var $target = $(e.currentTarget); ..... $.getJSON("/somelink.js ...

Tips for dynamically updating an HTML value with Javascript

Summary of My Issue: This involves PHP, JS, Smarty, and HTML <form name="todaydeal" method="post"> <span id="fix_addonval"></span> <input type="radio" name="offer" id="offer_{$smarty.section.mem.index+1}" value="{$display_offe ...

What is the proper method for submitting a mail form via AJAX without using jQuery?

Currently, I am working on integrating a PHP mail form with AJAX. The aim is to create a straightforward form that collects user information such as phone numbers and sends it to my email address. While I have managed to set up the form to send emails usi ...

Content will not render when JavaScript generates SVGs

As I delve into the world of JavaScript and SVG to create interactive graphics for a website, I've run into a puzzling issue with programmatically generated SVG paths not being drawn. Below is a sample code that highlights this problem: <!DOCTYPE ...

The Jquery datepicker value from UIGRid is not being retrieved when attempting to submit the form

I have implemented a jQuery Datepicker in a UI-Grid cell with the following code: { name: 'RDD', displayName: 'RDD', cellTemplate:'<input type="text" class="datepicker" id="{{row.entity.PartID}}" ng-model="row.entity.RDD" ng ...

Issues with executing Unit Tests in Karma using Webpack and Jasmine

Trying to set up testing with Karma, Jasmine, and Webpack in AngularJS has been quite a journey for me. While my webpack is functioning smoothly and I can run my website using npm start, things take a turn when I attempt to include my app.js. Despite nume ...

Combine several items to form a single entity

When I have two objects returned from the database, my goal is to combine them into one object. Here are the examples: { "id": 4, "first_name": "s", "last_name": "a", ...

Can you explain what the state represents in the $stateProvider?

I'm brand new to Ionic and AngularJS. I would greatly appreciate it if someone could share a tutorial with me that breaks down the syntax of $stateprovider. Specifically, I would like to understand what the .state element refers to and how it should b ...

implementing a sidebar menu using AngularJS

I am currently working with bootstrap and AngularJS to create a sidebar menu. Here is the code I have for it: <ul class="nav navbar-nav"> <li><a href="#"><span class="glyphicon glyphicon-send"></span> Link</a& ...

Sending data to mongodb using the fetch API and FormData method is a simple process that involves constructing

I have been trying to send data to mongoDB using the fetch API along with FormData, but encountering an error: POST https://xxxxxxxxxxxxxxxxxxxxxxxx/upload 500 (Internal Server Error) The form data in my EJS file appears as follows: <div id=" ...

How can we utilize data retrieved from Mongodb in Express and pass it to a Jade view using the res.render function?

Within my node/express application, I need to pass data retrieved from mongoose to my jade view. The code below in routes.js accomplishes this task: app.get('/newrequest', function (req, res) { Account.find({}, function (err, data) { ...

Click a button to switch the visibility of a section in an

Is there a way to create a toggle feature in Angular.JS that will open and close a div when clicked on the same div again? Currently, it opens the div when clicked but I want it to also close the div when clicked again. <a ng-href ng-click="openAccordi ...

The content of xmlhttp.responseText is not being displayed in the innerHTML

As part of my ongoing effort to enhance my understanding of Ajax for work purposes, I have been following the W3Schools tutorial and experimenting with my Apache2 server. In this process, I have placed a file named ajax_info.txt on the server (in /var/www ...

Looking for assistance with REGEXP to handle a 404 path rendering issue

I am attempting to utilize REGEXP in order to display a 404 page within a react app based on the path, but I am struggling to make it work. This is the specific REGEXP pattern I am trying to achieve: The entire path should not be '/' and should ...