/*
------------------------------------------------ ----------------------------------
Nome do arquivo: check.js
Descrição: script JavaScript, usado para verificar a entrada do formulário de envio da página web
Versão dos dados: 1.0
*/
/*
Objetivo: Verificar o formato do endereço IP
Entrada: strIP: endereço IP
Retorno: Se passar na verificação retorna verdadeiro, caso contrário retorna falso;
*/
function isIP(strIP) {
if (isNull(strIP)) return false;
var re=/^(d+).(d+).(d+).(d+)$/g // Expressão regular correspondente ao endereço IP
if(re.test(strIP))
{
if( RegExp.$1 <256 && RegExp.$2<256 && RegExp.$3<256 && RegExp.$4<256) return true
}
return false
}
;
/*
Objetivo: verificar se a string de entrada está vazia ou com todos os espaços
Entrada: str
Retorno:
Se estiver tudo vazio, retorne verdadeiro, caso contrário, retorne falso
*/
function isNull( str ){
if ( str == "" ) return true. ;
var regu = "^[]
+$
"
;
/*
Objetivo: verificar se o valor do objeto de entrada está em conformidade com o formato inteiro
. Entrada: str A string de entrada
retorna: verdadeiro se passar na verificação, caso contrário, falso.
*/
function isInteger( str ){
var
regu = /^[-]{0,1}
[0-9]{1,}$/;
/*
Objetivo: verificar se o número do celular inserido
foi digitado corretamente:
s: string
return:
true se passar na verificação, caso contrário, false
*/
function checkMobile( s ){
var
regu =/
^[1
][3][0-9]{9}$/;
verdadeiro;
}else{
retorna
falso
;
/*
Objetivo: verificar se a string de entrada está em conformidade com o formato de número inteiro positivo
. Entrada:
s: string
return:
true se passar na verificação, caso contrário, false.
*
/
function isNumber( s ){
var
regu = "^[
0-9]+$"
;
{
retornar falso;
}
}
/*
Objetivo: Verificar se a string de entrada está em formato digital com decimais, pode ser uma
entrada negativa:
s: string
return:
true se passar na verificação, caso contrário false
*/
function isDecimal( str ){
if(isInteger(str)) return true
var re = /^[-]{0,1}(d+)[.]+(d+)$/
; .test(str)) {
if
(RegExp.$1==0&&RegExp.$2==0
)
retornar
falso
;
/*
Objetivo: verificar se o valor do objeto de entrada está em conformidade com o formato do número da porta
. Entrada: str A string de entrada
retorna: verdadeiro se passar na verificação, caso contrário, falso.
*/
function isPort( str ){
return (isNumber(str) && str<65536
}
);
/*
Objetivo: verificar se o valor do objeto de entrada está em conformidade com o formato de E-Mail
Entrada: str A string de entrada
retorna: verdadeiro se passar na verificação, caso contrário, falso
*/
function isEmail( str ){
var meuReg = /^[-_A-Za-z0-9]+@([_A-Za-z0-9]+.)+[A-Za-z0-9]{ 2,3}$/;
if
(myReg.test(str)) return true
;
/*
Objetivo: Verificar se a string de entrada está em conformidade com o formato do valor
O formato é definido como um número positivo com ponto decimal, e até três dígitos podem
ser inseridos após o ponto decimal:
s: string
return:
true se a verificação. é passado, caso contrário falso
*/
function isMoney( s ){
var regu = "^[0-9]+[
.][0-9]
{0,3}$";
(s)) {
return true
} else {
return false
}
}
/*
Objetivo: verificar se a string de entrada consiste apenas em letras, números e sublinhados em inglês
. Entrada:
s: string
return:
retorna true se passar na verificação. retornar falso
*/
function isNumberOr_Letter( s ){//Determina se é um número ou uma letra
var regu = "^[0-9a-zA-Z_]+$";
var
re = new
RegExp
(
regu
)
;
/*
Objetivo: verificar se a string de entrada consiste apenas em letras e números em inglês.
Entrada:
s: string
return:
true se passar na verificação, caso contrário, false.
*/
function isNumberOrLetter( s ){//Determina se é um número ou uma letra
var regu = "^[0-9a-zA-Z]+$";
var re = new RegExp(regu);
if
(re.test(s)) {
return true
}
else{
return false
;
Objetivo: verificar se a string de entrada consiste apenas em caracteres chineses, letras e números.
Entrada:
valor: String
Retorno:
verdadeiro se for aprovado na verificação, caso contrário, falso.
*/
function isChinaOrNumbOrLett( s ){//Determine se é composto de caracteres chineses, letras e números
var regu = "^[0-9a-zA-Zu4e00-u9fa5]+$";
var
re = newRegExp
(regu
)
;
;
}
}
/*
Objetivo: Determinar se é uma
entrada de data: data: data; fmt: formato de data
Retorno: se passar na verificação, retorne verdadeiro, caso contrário, retorne falso
*/
function isDate(date, fmt) {
if (fmt==null) fmt="yyyyMMdd ";
var yIndex = fmt.indexOf("yyyy");
if(yIndex==-1) return
false
; "MM") ;
if(mIndex==-1) return false;
var
mês = data.substring(mIndex,mIndex+2)
; retornar falso;
var dia = data.substring(dIndex,dIndex+2);
if(!isNumber(ano)||ano>"2100" || ano< "1900") retornar falso
if(!isNumber(mês)| |mês>" 12" || mês< "01") return false;
if(dia>getMaxDay(ano,mês)
|| dia< "01") return false
;
function getMaxDay(ano,mês) {
if
(mês==4||mês==6||mês==9||mês==11)
return
"30";
==0&&ano%100!=0 || ano%400==0)
retorne
"
29
"
;
/*
Objetivo: se o caracter 1 termina com string 2
Entrada: str1: string; str2: string incluída
Retorno: se passar na verificação, retorna verdadeiro, caso contrário retorna falso
*/
function isLastMatch(str1,str2)
{
var index = str1.lastIndexOf(str2);
if(str1.length==index+str2.length) return true
}
;
/*
Objetivo: se o caracter 1 começa com a string 2
input: str1: string; str2: string incluída
Retorno: se passar na verificação, retorna verdadeiro, caso contrário retorna falso
*/
function isFirstMatch(
str1
,str2)
{
var índice = str1.indexOf(str2)
;
/*
Objetivo: O caractere 1 é uma string contendo 2
Entrada: str1: string; str2: string incluída
Retorno: se passar na verificação, retorna verdadeiro, caso contrário, retorna falso
*/
function isMatch(str1,str2)
{
var índice = str1.indexOf(str2);
if(index==-1) return false
}
;
/*
Objetivo: verificar se as datas de início e término inseridas estão corretas A regra é que o formato das duas datas esteja correto
e o término seja conforme programado >= data de início
entrada:
startDate: data de início, string
endDate: término como. agendado,
retorno de string:
se aprovado, a verificação retorna verdadeiro, caso contrário, retorna falso
*/
function checkTwoDate( startDate,endDate) {
if( !isDate(startDate
) ) {
alert("A data de início está incorreta!"
)
;
Incorreto!");
return false;
} else if( startDate > endDate ) {
alert("A data de início não pode ser maior que a data de término!");
return false;
}
return true;
}
/*
Objetivo: verificar se o formato da caixa de correio de e-mail inserido
foi inserido corretamente:
strEmail: string
return:
verdadeiro se aprovado na verificação, caso contrário, falso
*/
function checkEmail(strEmail) {
//var emailReg = /^[_a-z0-9]+@([_a-z0-9]+.)+[a-z0-9]{2,3}$ /;
var emailReg = /^[w-]+(.[w-]+)*@[w-]+(.[w-]+)+$/
; (strEmail) ){
returntrue
;
}
else{
alert("O formato do endereço de e-mail que você digitou está incorreto!")
;
/*
Objetivo: verificar se o formato do número de telefone inserido está correto
Digite:
strPhone: string
return:
true se passar na verificação, caso contrário, false.
*/
function checkPhone( strPhone ) {
var phoneRegWithArea = /^[0][1-9]{2,3}-[0-9]{5,10}$/;
var phoneRegNoArea = /^[1-9] {1}[0-9]{5,8}$/;
var prompt = "O número de telefone que você digitou está incorreto!"
if( strPhone.length > 9 ) {
if( phoneRegWithArea.test(strPhone) ){
return true ;
}else{
alerta( prompt );
retornar falso
}
}else
{
if( phoneRegNoArea.test( strPhone ) )
{
retornar
verdadeiro
;
}
}
/*
Objetivo: Verificar o número de caixas de seleção selecionadas.
Entrada:
checkboxID: string
Retorno:
Retornar o número de caixas de seleção selecionadas.
*/
function checkSelect (checkboxID) {
var check = 0;
var i=
0
;
if(document.all(checkboxID).item(i).checked) {
verificar += 1
}
;
}
}else{
if(document.all(checkboxID).checked )
verificação
=
1
;
função getTotalBytes(varField) {
if(varField == null)
return -1;
var totalCount = 0;
for (i=
0;i
< varField.value.length; i++) {
if
(varField.value.charCodeAt(i
) > 127)
totalCount += 2
;
função getFirstSelectedValue(checkboxID){
var
valor = null;
var i=0
;
if
(document.all(checkboxID).item( i ).checked ){
valor = document.all(
checkboxID
).item(i).value
break
;
)
valor = document.all(checkboxID).valor
}
valor de retorno
}
função getFirstSelectedIndex
(
checkboxID) {
var valor = -2;
var i = 0
;
{
if(document.all(checkboxID).item( i ).checked ) {
valor = i
}
}
} else {
if( document.all(checkboxID).checked
)
valor
=
-1
;
função selectAll(checkboxID,status){
if(document.all(checkboxID) == null)
retorno;
if(document.all(checkboxID).length > 0 ){
for( i=0; i<document.all(checkboxID).length; i++ ){
document.all(checkboxID).item( i ).checked = status
}
} else {
document.all(checkboxID).checked = status
} }
;
função selectInverse(checkboxID) {
if(document.all(checkboxID) == null)
return;
if(document.all(checkboxID).length > 0 ) {
for( i=0; i<document.all(checkboxID).length; i++ ) {
document.all(checkboxID).item( i ).checked = !document .all(checkboxID).item( i ).checked;
else
{
document.all
(checkboxID).checked = !document.all(checkboxID).checked
;
function checkDate( value ) {
if(value=='') return true;
if
(value.length!=8 || !isNumber(value)) return false
;
ano>"2100" || ano< "1900")
retorna falso;
var mês = valor.substring(4,6);
if(mês>"12" || mês< "01") return false;
var dia = valor.substring(6,8);
if(dia>getMaxDay(ano,mês) || dia< "01") return false;
retornar verdadeiro;
}
/*
Objetivo: verificar se as datas deinício
e término inseridas estão corretas. A regra é que o formato das duas datas esteja correto ou ambas estejam vazias
e
a data de término >= data de início
. data de término, string
return:
Retorna verdadeiro se a verificação for aprovada, caso contrário, retorna falso
*/
function checkPeriod( startDate,endDate) {
if( !checkDate(startDate
) ) {
alert("A data de início está incorreta!"
)
;
Incorreto!");
return false;
} else if( startDate > endDate ) {
alert("A data de início não pode ser maior que a data de término!");
return false;
}
return true;
}
/*
Objetivo: verificar se o código de segurança
foi inserido corretamente:
secCode: código de segurança
return:
verdadeiro se a verificação for aprovada, caso contrário, falso
*/
function checkSecCode( secCode ) {
if( secCode.length!
=6 ){
alert("O comprimento do código de segurança deve ser de 6 dígitos")
;
if(!isNumber( secCode ) ){
alert("Os códigos de segurança só podem conter números");
retorne falso;
}
retorne verdadeiro
}
/********************************************** ***** ***
function:cTrim(sInputString,iType)
description: Função para remover espaços dos
parâmetros da string: iType: 1=Remover espaços do lado esquerdo da string
2=Remover espaços no lado esquerdo da string
0=Remover espaços nos lados esquerdo e direito da string
valor de retorno: String com espaços removidos
******************* ***** ******************************/
function cTrim(sInputString,iType)
{
var sTmpStr = ' ';
var eu = -1;
if(iType == 0 || iType == 1)
{
while
(sTmpStr==
' ')
{
++
i
;
if(iType
==
0||
iType == 2)
{
sTmpStr = ' ';
i
=
sInputString.length
;
sInputString = sInputString.substring(0,i+1 }
return
sInputString
}
/*
------------------------------------------------ ----------------------------------
Descrição: script JavaScript, verifique os itens de dados no formulário start
--- ---- ---------------------------------------------- ---- -----------------------
*/
function checkForm(objFrm){
var len = 0
;
var i =
0
;
var
objCheck
; objCheck) ){
retornar falso;
}
}
//Caixa suspensa
for(i = 0; i < len; i ++){
objCheck = objFrm.elements[i]
; {
retornar falso;
}
}
//O período de tempo é válido
if( f_checkStartAndEndDate(objFrm) == false) return false;
return true;
}
function f_checkSelectValid(obj){
//alert("check select");
if(obj.options.length <= 0){
alert("Nenhum dado na caixa de seleção suspensa!")
;
}
retornar verdadeiro
}
função
f_checkStartAndEndDate(frm)
{
var
len
=
frm.elements.length
;
objEndDate;
//alert("verificação do período de data de início");
try{
for(i=0; i< len ; i++){
objCheck = frm.elements[i
]
;
"startDate") >0 ||temp.indexOf("beginDate")>0 )
objStartDate = objCheck;
if( temp.indexOf("endDate") > 0 )
objEndDate = objCheck;
}
//alert(objStartDate.value);
//alert(objEndDate.value);
if(objStartDate.value==null || objStartDate.value == || objStartDate.value ==null || objStartDate.value = = ""){
return true;
}
return checkTwoDate(objStartDate.value, objEndDate.value);
//alert("verificação do período de data final");
}catch(E){}
return true
}
function f_checkTextValid(obj){
//Não pode estar vazio
if(obj.getAttribute("isNeed") != null){
if(f_isNotNull(obj) == false) return false
}
//Não pode exceder o comprimento
if(obj. getAttribute ("maxlength") != null){
if
(f_checkLength(obj) == false) return false;
}
var checkType =""
;
checkType == "") return true;
//
if (checkType.indexOf("number") >=0){
if(
f_isNumber(obj) == false) return false;
) retorna falso;
}
//
if (checkType.indexOf("positivo") >=0){
if(f_isNumber(obj) == false) return false;
if
(f_isPositive(obj)==false) return false;
checkType) == falso) retorna falso;
}
if (checkType.indexOf("data") >=0){
if(f_checkDate(obj) == false) return false;
}
/*
switch(checkType){
case "número": if(f_isNumber(obj) == false) return false;break;
case "date": if(f_checkDate(obj) == false) return false;break;
padrão:
}
*/
retornar verdadeiro;
}
função f_isNotNull(obj){
if(obj.value == ""){
f_alert
(
obj, "Valores
nulos não são permitidos!")
;
function f_isNumber(obj){
if(isNaN(obj.value)){
f_alert(obj,"deve ser um tipo numérico")
;
}
retornar verdadeiro;
}
function f_checkDate(obj) {
if(checkDate(obj.value) ==false){
f_alert(obj,"Não é um formato de data legal!")
;
}
retornar verdadeiro;
}
function f_checkLength(obj){
if(getTotalBytes(obj) > Math.abs( obj.getAttribute("maxlength") ) ){
f_alert(obj,"Limite de comprimento excedido!")
;
}
retornar verdadeiro;
}
function f_alert(obj,alertStr){
var fielName = obj.getAttribute("fieldName");
if
(fielName == null)
fielName = ""
;
obj.foco()
;
function f_checkNumType(obj, numType){
//Suposição: o julgamento do tipo numérico foi realizado
var
strTemp;
var numpric
;var
numLen
;
tente{
if(numType == null|| numType =="") return f_checkNumLenPrec(obj,defaultLen
, defaultpric);
) retornar f_checkNumLenPrec(obj,defaultLen, defaultpric);
strTemp = numType.substr( numType.indexOf("(") + 1 ,numType.indexOf(")") - numType.indexOf("(") -1 );
se (strTemp == null||strTemp =="") return f_checkNmLenPrec(obj,defaultLen, defaultpric
= strTemp.split(",");
numLen
=
Math.abs( strArr[0] );
return f_checkNumLenPrec
(
obj,numLen, numpric);
}catch(e){
alert("in f_checkNumType = " + e)
;
}
função f_checkNumLenPrec(obj, len, pric){
var numReg
var
valor = obj.value;
//alert(valor + "=====" + len + "====="+ preço)
;
numReg =/[-]/;
strValueTemp = value.replace(numReg, "");
strValueTemp
= strValueTemp.replace(
numReg
, "");
]/;
//alert(numReg.test(value));
if(numReg.test(value) == true){
f_alert(obj, "A entrada deve ser do tipo inteiro!")
;
}
}
if(strValueTemp.indexOf(".") < 0 ){
//alert("lennth==" + strValueTemp);
if(strValueTemp.length >(len - pric)){
f_alert(obj, "O número de dígitos inteiros não pode exceder "+ (len - pric) +" bits"
)
;
}else{
strInt = strValueTemp.substr( 0, strValueTemp.indexOf(".") );
//alert("lennth==" + strInt);
if(strInt.length >(len - pric)){
f_alert(obj, "O número de dígitos inteiros não pode exceder "+ (len - pric) +" bits
return false
}
;
strDec = strValueTemp.substr( (strValueTemp.indexOf(".")+1), strValueTemp.length );
//alert("pric==" + strDec);
if(strDec.length > pric){
f_alert(obj, "Onúmero
de casas decimais não pode exceder "+ pric +" casas")
;
}
retornar verdadeiro;
}
catch(e){
alerta("in f_checkNumLenPrec = " + e)
;
}
function f_isPositive(obj){
var numReg =/[-]/;
if(numReg.test(obj.value
) == true){
f_alert
(obj, "Deve
ser um número positivo!");
verdadeiro ;
}
/*
function selectedCheckboxCount(form)
Descrição da função: Conta as opções selecionadas no Form
Descrição do parâmetro:
form: o formulário especificado
*/
function selectedCheckboxCount(form){
var
length =0
;
var count =
0
;
item(i);
//tipo = obj.attributes.item("tipo").nodeValue;
tipo = obj.type;
if(type == "caixa de seleção"){
if
(
obj.checked
)
{
contagem++
}
i++
;
//Obter o comprimento de bytes
function getByteLen(str)
{
var l = str.length;
var n = l
for ( var i=0; i<l; i++ )
if ( str.charCodeAt(i) <0 || str.charCodeAt(i) >255 )
n=n+1
retornar n
};
/*
Instruções:
1. Limpe os dados da tabela (0,0 e 0)
2. Se não houver dados na célula, um espaço será adicionado automaticamente
3. Desmarque a caixa de seleção da linha em branco
Parâmetros:
clearzero: se deve limpar "0" e "0.0", false para não limpar, true para limpar (o padrão é true)
tablename: nome da tabela a ser limpa, o padrão é sortTable
*/
function clear_table(clearzero,tablename)
{
var tobject;
if (tablename==null)
tobject=gmobj("sortTable");
else
tobject
=gmobj(tablename);
if(tobject==null)
return;
//Se o parâmetro de chamada de função estiver vazio, significa que 0 e 0.0 devem ser limpos; caso contrário, 0 e 0.0 não devem ser limpos;
var claro = (clearzero==nulo)?true:clearzero;
//Limpar 0, 0.0, preencher os espaços
var rows = tobject.rows;
for
(var i=0;i<rows.length;i++)
{
//Limpar o atributo da primeira célula, se for 1, indicando que não há dados nesta linha, limpe todos os dados nesta linha
while(tobject.rows[i].cells[j] != null)
{
if(clear)
{
if(tobject.rows[i].cells[j].innerHTML==0 ||tobject.rows[i]. células[j].innerHTML==0.0||tobject.rows[i].cells[j].innerHTML=="")
tobject.rows[i].cells[j].innerText=" "
}
else
{
if (tobject.rows[i].cells[j].innerHTML=="")
tobject.rows[i].cells[j].innerText=" "
}
j++
}
j=0;
}
retornar verdadeiro;
}
function gmobj(mtxt) /* Obter objeto pelo nome do objeto */
{
if (document.getElementById) {
m=document.getElementById(mtxt }
else if (document.all) {
m=document.all[mtxt]
}
;senão if (document.layers) {
m
=
document.layers[mtxt]
}
return m
;
-------------------------------------------------- ---
Descrição: script JavaScript, verifique os itens de dados no final do formulário
---------------------------------- --------------------------------------------------
*/
/*
Objetivo: verificar se a string de entrada é um formato numérico com decimais, que pode ser um número negativo (e atender à precisão especificada)
input: str: string
l: número total de dígitos
d: número de dígitos após o ponto decimal
Return :
verdadeiro se a verificação for aprovada, caso contrário, retorne falso
*/
function isDecimal( str,l,d ){
if(isInteger(str)) {
if
(l==null)return
true;
verdadeiro;
}
var re = /^[-]{0,1}(d+)[.]+(d+)$/;
if (re.test(str)) {
if (l==null) return true
se
;(d==nulo) d
=
0
;
=d) retornar verdadeiro;
}
retornar falso
}
onclick="isNull('Co.PageForm.NomeConcorrente');"