Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

i want a js to validate current date with entered date and to replace a image

New Here ,
May 06, 2018 May 06, 2018

hai pls help me out of this

1.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 08, 2018 May 08, 2018

In what context? A web-page? A PDF file? Something else? You need to provide more details...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 15, 2018 May 15, 2018
LATEST

Regardless of the application, JS has a Date object that can perform that comparison very simple using vanilla JS. It would be something like (ES5):

// create date to test and todays date

var testDate = new Date( '12/25/2018' ); // MM/DD/YYYY

var todaysDate = new Date(); // today, per the computer that's running the JS engine

// compare

if ( testDate.setHours(0,0,0,0) == todaysDate(0,0,0,0) ) {

     // true, today

} else {

     // false, not today

}

As for the image, if it's on the web or Acrobat or something else, we'll need to know. On the web the vanilla ES5 way is simply alter the 'src' property of the image, and hopefully give it a class or an ID so you can easily locate it. Plain ES5 e.g.:

<!-- HTML -->

<img src="images/mypic.png" id="someImage">

// JS

<script type='text/javascript'>

// wait for window to load

window.addEventListener( 'load', function() {

     // change image .src attribute via ID

     document.getElementById( 'someImage' ).src = 'images/anotherimage.png';

});

</script>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines