﻿// works only with decimal char = "." 

// controlbyid: Permite obter boa funcionalidade tanto no IE como no FireFox

// arguments.Value   
//      inicia com cópia de document.all(source.controltovalidate).value; 
//      pode ser alterado ser modificar a TextBox

// IE => document.all(source.controltovalidate).value
// FIREFOX => document.getElementById(source.controltovalidate).value)
//      aponta para o valor da TextBox

// arguments.IsValid
//      armazena a resposta da validação   

function controlbyid(id) {
return (document.getElementById) ? document.getElementById(id) : document.all[id];
}

function ValidateRealPos(source,arguments){
    try { arguments.Value=eval(arguments.Value); }
    catch(err) { ;/* do nothing */}
    if (isNaN(arguments.Value)) arguments.IsValid=false;
    else {
        controlbyid(source.controltovalidate).value=arguments.Value;
        if (arguments.Value>0) arguments.IsValid=true; else arguments.IsValid=false;
    }
}
function ValidateRealPos0(source,arguments){
    try { arguments.Value=eval(arguments.Value); }
    catch(err) { ;/* do nothing */}
    if (isNaN(arguments.Value)) arguments.IsValid=false;
    else {
        controlbyid(source.controltovalidate).value=arguments.Value;
        if (arguments.Value>=0) arguments.IsValid=true; else arguments.IsValid=false;
    }
}
function ValidateRealNeg(source,arguments){
    try { arguments.Value=eval(arguments.Value); }
    catch(err) { ;/* do nothing */}
    if (isNaN(arguments.Value)) arguments.IsValid=false;
    else {
        controlbyid(source.controltovalidate).value=arguments.Value;
        if (arguments.Value<0) arguments.IsValid=true; else arguments.IsValid=false;
    }
}
function ValidateReal(source,arguments){
    try { arguments.Value=eval(arguments.Value);}
    catch(err) { ;/* do nothing */}
    if (isNaN(arguments.Value)) arguments.IsValid=false;
    else {
        controlbyid(source.controltovalidate).value=arguments.Value;
        arguments.IsValid=true; 
    }
}
function ValidateIntPos(source,arguments){
    try {
        arguments.Value=eval(arguments.Value); 
        arguments.Value=parseInt(arguments.Value); 
    }
    catch(err) { ;/* do nothing */}
    if (isNaN(arguments.Value)) arguments.IsValid=false;
    else {
        controlbyid(source.controltovalidate).value=arguments.Value;
        if (arguments.Value>0) arguments.IsValid=true; else arguments.IsValid=false;
    }
}
function ValidateIntPos0(source,arguments){
    try {
        arguments.Value=eval(arguments.Value); 
        arguments.Value=parseInt(arguments.Value); 
    }
    catch(err) { ;/* do nothing */}
    if (isNaN(arguments.Value)) arguments.IsValid=false;
    else {
        controlbyid(source.controltovalidate).value=arguments.Value;
        if (arguments.Value>=0) arguments.IsValid=true; else arguments.IsValid=false;
    }
}
