﻿//อนุญาตให้กรอกได้แค่ตัวเลข 
function AllowNumericOnly()
{
    // Get the ASCII value of the key that the user entered
    var key = window.event.keyCode;

    // Verify if the key entered was a numeric character (0-9) 
    if ( (key > 47 && key < 58))
        // If it was, then allow the entry to continue
        
        return;
    else
        // If it was not, then dispose the key and continue with entry
        window.event.returnValue = null; 
}

//อนุญาตให้กรอกได้แค่ตัวเลขและเครื่องหมายจุด (.)
function AllowNumericDecimal()
{
    // Get the ASCII value of the key that the user entered
    var key = window.event.keyCode;

    // Verify if the key entered was a numeric character (0-9) or a decimal (.)
    if ( (key > 47 && key < 58) || key == 46 )
        // If it was, then allow the entry to continue
        
        return;
    else
        // If it was not, then dispose the key and continue with entry
        window.event.returnValue = null; 
}

function CalAmt(price,amt)
{
        //document.getElementById('amt').value=0;//document.getElementById('price').value;
        txb1=MM_findObj(price);
        txb2=MM_findObj(amt);
        //txb1=document.getElementById('price');
        //txb2=document.getElementById('amt');
       //alert(eval(txb2.value));//txb1.value;
        txb2.value=eval(txb1.value);
}


//อนุญาตให้กรอกได้แค่ตัวเลขและเครื่องหมายจุด เปอร์เซนต์ บวก (. % +)
function ValidateStringDiscount()
{
    // Get the ASCII value of the key that the user entered
    var key = window.event.keyCode;
//    alert(key);
    // Verify if the key entered was a numeric character (0-9) or (. % +)
    if ( (key > 47 && key < 58) || key == 46 || key == 37|| key == 43)
        // If it was, then allow the entry to continue
        return;
    else
        // If it was not, then dispose the key and continue with entry
        window.event.returnValue = null; 
}

//อนุญาตให้กรอกได้แค่ Y,N
function AllowOnlyYesNo()
{
    // Get the ASCII value of the key that the user entered
    var key = window.event.keyCode;
    // Verify if the key entered was a y,Y,n,N
    if ( key == 121 || key == 89 || key == 110 ||key == 78 )
        // If it was, then allow the entry to continue
        return;
    else
        // If it was not, then dispose the key and continue with entry
        window.event.returnValue = null; 
}

//check numeric for input
function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
}
