owkaye
07-14-2011, 02:31 AM
My Javascript doesn't display an error when the "bid" field is blank but I want it to. Can someone help me fix it? Everything else works okay but I'm not a Javascript programmer so I don't know where to begin.
function checkBid(fieldName,minValue,maxValue){
var numberfield = fieldName;
if (chkNumeric(fieldName,minValue,maxValue) == false){
numberfield.select();
numberfield.focus();
return false;
}
else{
return true;
}
}
function chkNumeric(fieldName,minValue,maxValue){
var checkOK = "0123456789";
var checkStr = fieldName;
var allValid = true;
var decPoints = 0;
var allNum = "";
for (i = 0; i < checkStr.value.length; i++){
ch = checkStr.value.charAt(i);
for (j = 0; j < checkOK.length; j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length){
allValid = false;
break;
}
if (ch != ",")
allNum += ch;
}
if (!allValid){
alertsay = "The bid field contains one or more invalid characters:\nPlease use only numeric digits in this field ...\n "
alert(alertsay);
return (false);
}
var chkVal = allNum;
var prsVal = parseInt(allNum);
if (chkVal != "" && !(prsVal >= minValue && prsVal <= maxValue)){
alertsay = "Your bid value is outside the acceptable bidding range:\nPlease enter a value from "+minValue+" to "+maxValue+" ...\n "
alert(alertsay);
return (false);
}
}
function checkBid(fieldName,minValue,maxValue){
var numberfield = fieldName;
if (chkNumeric(fieldName,minValue,maxValue) == false){
numberfield.select();
numberfield.focus();
return false;
}
else{
return true;
}
}
function chkNumeric(fieldName,minValue,maxValue){
var checkOK = "0123456789";
var checkStr = fieldName;
var allValid = true;
var decPoints = 0;
var allNum = "";
for (i = 0; i < checkStr.value.length; i++){
ch = checkStr.value.charAt(i);
for (j = 0; j < checkOK.length; j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length){
allValid = false;
break;
}
if (ch != ",")
allNum += ch;
}
if (!allValid){
alertsay = "The bid field contains one or more invalid characters:\nPlease use only numeric digits in this field ...\n "
alert(alertsay);
return (false);
}
var chkVal = allNum;
var prsVal = parseInt(allNum);
if (chkVal != "" && !(prsVal >= minValue && prsVal <= maxValue)){
alertsay = "Your bid value is outside the acceptable bidding range:\nPlease enter a value from "+minValue+" to "+maxValue+" ...\n "
alert(alertsay);
return (false);
}
}