javascript - Scroll to top of IFrame when submit the form in iframe -


i have form placed in iframe.i have added javascript function validation. rise error message when click submit button without filling mandatory fields.

the form contains more 8 fields. error message displayed in top of page. when click submit button, stays bottom of page. that, error message not visible.

for scroll in iframe, have added following code,

parent.parent.window.scroll(0,0); 

it takes me top of page in iframe.but , skips javascript validation. passes request without validation.

please me on one.

thanks in advance

set id error's wrapping div, use javascript's window.location move internally id, after - , depending- mandatory field validation code (you can put in conditional statement). example on how use it:

<!doctype html>   <html>     <head>       <script>         function scroll(){           window.location = '#error';         }       </script>     </head>     <body>       <div id='error'>         <p>error: error message.</p>       </div>       <iframe src="http://www.yahoo.com" width="400" height="800">       </iframe>       </br>       <input type="button" onclick="scroll()" value="scroll"></input>     </body>   </html> 

you can use jquery scroll smoothly it:

http://www.paulund.co.uk/smooth-scroll-to-internal-links-with-jquery


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -