For this homework I have to write a javascript code to validate the birth year is greater than 1870 and less than the current year plus one how can I combine them to show the same error message?
function isYearofBirthValid(birth) {
"use strict";
var alert = "";
if(birth.length < 1870 && birth.length > 2013) { <---- this part?
alert("invalid year");
return false;
}
return true;
}
Try this if statement instead:
Or if you actually want to look up what the next year is
Then you call the function like so