|
Server : Apache/2.2.22 (Unix) mod_ssl/2.2.22 OpenSSL/1.0.0-fips mod_auth_passthrough/2.1 mod_bwlimited/1.4 System : Linux server.jackjohnson.com 2.6.32-279.5.2.el6.x86_64 #1 SMP Fri Aug 24 01:07:11 UTC 2012 x86_64 User : jackjohn ( 502) PHP Version : 5.3.17 Disable Function : NONE Directory : /home/jackjohn/public_html/shopsite-images/en-US/javascript/shipping/ |
Upload File : |
function check_dimensions(l, w, h)
{
var length, width, height;
if (l != null && w != null && h != null)
{
// check if any dimensions have been entered
if (l.value.length > 0 || w.value.length > 0 || h.value.length > 0)
{
if (l.value.length == 0)
{
focusOn(l);
alert(enter_length_dimension);
return false;
}
if (w.value.length == 0)
{
focusOn(w);
alert(enter_width_dimension);
return false;
}
if (h.value.length == 0)
{
focusOn(h);
alert(enter_height_dimension);
return false;
}
// normalize decimal points
length = l.value.replace(',', '.');
width = w.value.replace(',', '.');
height = h.value.replace(',', '.');
// must be valid numbers
if (isNaN(length))
{
focusOn(l);
alert(length_not_a_number);
return false;
}
if (isNaN(width))
{
focusOn(w);
alert(width_not_a_number);
return false;
}
if (isNaN(height))
{
focusOn(h);
alert(height_not_a_number);
return false;
}
length = Number(length);
width = Number(width);
height = Number(height);
// cannot be zero or negative
if (length <= 0)
{
focusOn(l);
alert(invalid_dimension);
return false;
}
if (width <= 0)
{
focusOn(w);
alert(invalid_dimension);
return false;
}
if (height <= 0)
{
focusOn(h);
alert(invalid_dimension);
return false;
}
// cannot be smaller than 0.01
if (length < 0.01)
{
focusOn(l);
alert(dimension_too_small);
return false;
}
if (width < 0.01)
{
focusOn(w);
alert(dimension_too_small);
return false;
}
if (height < 0.01)
{
focusOn(h);
alert(dimension_too_small);
return false;
}
// length must be the larger dimension
if (length < width || length < height)
{
focusOn(l);
alert(length_must_be_greater);
return false;
}
}
}
return true;
}
function focusOn(element)
{
var elem = $(element);
if (elem.is(':hidden'))
toggle_section(elem.closest('div.collapsible_section').prev().prev(), false);
elem.focus();
}