How to Create a Scroll To Top With Some Delay Using JavaScript ?

Here I am sharing the code for scrolling a page from bottom to top with some delay. You can also use that to reach or show first error element box in your specified form.  Show First Scrolled Error Element Box on Submit :- you can use below jQuery code to scroll on the first error element box on submit – $(‘html, body’).animate({ scrollTop: $(validator.errorList[0].element).offset().top-300 }, 2000); Above code will work for the form group on submit. for an example below – $(“#submit”).on(‘click’, function () { var validator = $(“#form”).validate({ rules:…

How to get current Date and Time using JavaScript || JavaScript Date Formats

This tutorial shows, how can you get the current date and time in JavaScript. Use the following JavaScript code to get current date and time with Y-m-dand H:i:s format. JavaScript Date object help us to work with date type of strings. Use new Date() to create a new object with current date and time. var today = new Date(); You can get current date from Date object in Y-m-d format. var date = today.getFullYear()+’-‘+(today.getMonth()+1)+’-‘+today.getDate(); You can get current time from Date object in H:i:s format. var time = today.getHours() + “:” + today.getMinutes() + “:” + today.getSeconds(); You can …