---
title: "Check if year is leap year in javascript"  
description: "Check if year is leap year in javascript"  
author: "Anonymous User"  
published: 2013-05-03  
updated: 2013-05-03  
canonical: https://www.mindstick.com/forum/796/check-if-year-is-leap-year-in-javascript  
category: "javascript"  
tags: ["javascript"]  
reading_time: 1 minute  

---

# Check if year is leap year in javascript

Hi Everyone!\
[function](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server) leapYear(year){ var [result](https://www.mindstick.com/blog/12011/advantages-of-getting-result-oriented-seo-from-an-agency); year = parseInt(document.getElementById("isYear").value); if (years/400){ result = true } else if(years/100){ result = false } else if(years/4){ result= true } else{ result= false } return result }This is what I have so far (the entry is on a from thus [stored](https://www.mindstick.com/forum/157561/what-is-the-stored-procedure-create-a-procedure-to-find-the-record-by-stu_id-from-the-student-table) in "isYear"), I basically followed this here, so using what I [already](https://yourviews.mindstick.com/view/88453/the-hidden-ways-ai-is-already-controlling-your-daily-life) have, how can I [check if](https://www.mindstick.com/forum/12878/how-to-check-if-an-asp-dot-net-file-upload-control-has-a-file-in-jquery) the \
entry is a [leap year](https://www.mindstick.com/forum/156857/write-a-c-sharp-program-to-check-leap-year) based on these conditions(note I may have done it wrong when implementing the pseudocode, please correct [me if](https://answers.mindstick.com/qa/50259/tell-me-if-your-system-is-infected-by-a-virus-how-you-will-recover-the-data) I have) Edit: Note this needs to \
use an [integer](https://answers.mindstick.com/qa/113667/write-code-for-roman-to-integer) not a date function\
Please help me!Thanks in [advance](https://www.mindstick.com/blog/33258/jee-mains-and-jee-advance-exams)!

## Replies

### Reply by AVADHESH PATEL

Hi Ankit!\
Try as following\
function leapYear(year){ return ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0);}


---

Original Source: https://www.mindstick.com/forum/796/check-if-year-is-leap-year-in-javascript

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
