Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var converter = function() {
- var = from = document.units.elements.from,
- fromWhat = document.units.elements.fromWhat,
- to = document.units.elements.to,
- toWhat = document.units.elements.toWhat;
- if (fromWhat.value === "Convert from" && toWhat.value === "Convert to") {
- alert("Please choose what you want to convert, and what you want it be converted to.");
- } else if (fromWhat.value === "Convert from") {
- alert("Please choose what you want to convert.");
- } else if (toWhat.value === "Convert to") {
- alert("Please choose what you want to convert to.");
- } else if ((isNaN(from.value) === true) || (isNaN(to.value) === true) || (from === null) || (from.value === undefined)) {
- alert("Please enter a number.");
- }
- else {
- to.value = fromWhat.value*fromWhat.value/toWhat.value;
- }
- return false;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement