javascript - How to validate a form when not scrolled down using angularjs? -


i trying validate form page called 'agree information'. here, user has scroll down in order move forward(remember no checkbox @ bottom of box, instead user has scroll down way till scroll ends), if user clicks continue/agree button without scrolling, div element/error must displayed saying 'scrolling bottom of information required'(must anchor link, clicking on should highlight box color). here code , 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 lookup 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> 

please let me know missing here or there other way?

agree information page

your condition needs little tweaking , it's go.

if (el.scrolltop === el.scrollheight - el.offsetheight) {   // scrolled bottom } 

jsfiddle demo: http://jsfiddle.net/030d6pb0/


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -