function ValidateChange(orderAmount,newAmount,Curr,P37)
{
var strNewAmount = newAmount;
if (IsNumeric(strNewAmount) == true)
{
if (strNewAmount.length != 0)
{
dot = ".";
comma = ",";
while (strNewAmount.indexOf(comma)>-1) {
pos = strNewAmount.indexOf(comma);
strNewAmount = "" + (strNewAmount.substring(0, pos) + dot +
strNewAmount.substring((pos + comma.length), strNewAmount.length));
}
while (orderAmount.indexOf(comma)>-1) {
pos = orderAmount.indexOf(comma);
orderAmount = "" + (orderAmount.substring(0, pos) + dot +
orderAmount.substring((pos + comma.length), orderAmount.length));
}
var dblorderAmount = parseFloat(orderAmount);
var dblnewAmount = parseFloat(strNewAmount);
var arrNewAmount = strNewAmount.split(".");
if(arrNewAmount.length == 2)
{
if (arrNewAmount[0] == '')
{
strNewAmount = "0" + strNewAmount;
dblnewAmount = parseFloat(strNewAmount);
dblnewAmount = dblnewAmount.toFixed(2);
}
if (arrNewAmount[1].length == 0)
{
strNewAmount = strNewAmount + "00";
dblnewAmount = parseFloat(strNewAmount);
dblnewAmount = dblnewAmount.toFixed(2);
}
if (arrNewAmount[1].length == 1)
{
strNewAmount = strNewAmount + "0";
dblnewAmount = parseFloat(strNewAmount);
dblnewAmount = dblnewAmount.toFixed(2);
}
if (arrNewAmount[1].length > 2)
{
dblnewAmount = dblnewAmount.toFixed(2);
strNewAmount = dblnewAmount;
}
}
if ((dblnewAmount <= dblorderAmount) && (arrNewAmount.length < 3))
{
while (strNewAmount.indexOf(dot)>-1) {
pos = strNewAmount.indexOf(dot);
strNewAmount = "" + (strNewAmount.substring(0, pos) + comma +
strNewAmount.substring((pos + dot.length), strNewAmount.length));
}
if (confirm("Are you sure you want to settle "+ strNewAmount +" "+ Curr +" ?")) {
window.open("Capture.asp?Action=Capture&Type=ChangeAmt&ID="+ P37 +"&newAmount="+ strNewAmount +"","link","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,fullscreen=no,width=446,height=250");
}
}
else{
alert('Invalid amount!');
}
}
else
{
alert('Invalid amount!');
}
}
else
{
alert('Invalid amount!');
}
}
Har ni några förslag?