📄 validation.js
字号:
// -----------------------------------------------------------------------------
// Generic Form Validation
//
// -----------------------------------------------------------------------------
// This function trims the input String. It removes the leading and trailing
// spaces from the String.
function trim(strText) {
// this will get rid of leading spaces
while (strText.substring(0,1) == ' ')
strText = strText.substring(1, strText.length);
// this will get rid of trailing spaces
while (strText.substring(strText.length-1,strText.length) == ' ')
strText = strText.substring(0, strText.length-1);
return strText;
}
// This function checks and tells if the field is Empty or not
// It returns true if the text in the fieldName given is empty and false if it is not
function isEmpty(strText){
var flag=false;
var trimmedText=trim(strText);
if(trimmedText.length < 1){
flag=true;
}
return flag;
}
// This function checks and tells if the field contains numbers greater than zero.
// It returns true if the text contains a number greater than zero or false otherwise.
function isNumber(strText){
val=new Object(trim(strText));
var flag=true;
if(isNaN(val)){
flag=false;
}else {
if((val < 0) || (val == 0)){
flag=false;
}
}
return flag;
}
// This function checks and tells if the character sent is present in the text or not.
// It returns true if the character is present and false otherwise.
function isCharPresent(specialChar,strText){
var flag=false;
if(trim(strText).indexOf(specialChar)!=-1){
flag=true;
}
return flag;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -