• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
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

Copy link to clipboard

Copied

hai pls help me out of this

Views

1.2K

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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>

Votes

Translate

Translate

Report

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