Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Array to get viewname for correspounding form name */
- /* Array to get viewname for correspounding form name */
- var viewName=new Array(
- ["frmAssignee","vwAssigneeDetails"],
- ["frmKeywords","vwKeywords"],
- ["frmInvoiceSuffix","vwInvoiceSuffix"]
- )
- /*function UniqueCheck (fieldvalue, fieldtext ,valueList)
- Description : Is used to check uniqueness of thye entry
- */
- function UniqueCheck (fieldvalue, fieldtext ,valueList)
- {
- var length,temp
- var i,exist
- var arr=new Array();
- arr = valueList.split("; ")
- length = arr.length
- for(i=0;i<length;i++)
- {
- if(Trim(fieldvalue.toLowerCase())==Trim(arr[i].toLowerCase()))
- {
- alert(fieldtext+" Already Exists")
- return 1;
- }
- }
- return 0;
- }
- /*
- function IsBlank (fieldvalue, fieldtext)
- Description: Is used to validate field for blank values
- */
- function IsBlank (fieldvalue, fieldtext)
- {
- if(Trim(fieldvalue)=="" || Trim(fieldvalue)=="----Select----")
- {
- alert("Please Enter "+ fieldtext);
- return 1;
- }
- return 0;
- }
- /*
- function IsBlankForList (fieldvalue ,fieldtext)
- Description: Is used to check for blank value for drop down fields
- */
- function IsBlankForList (fieldvalue ,fieldtext)
- {
- if(Trim(fieldvalue)=="" || Trim(fieldvalue)=="----- Please Select -----")
- {
- alert("Please Select "+ fieldtext);
- return 1;
- }
- return 0;
- }
- /*
- function ContainsSpecialChar(str)
- Description: Is used to check whether string contains a special charecter
- */
- function ContainsSpecialChar(fieldValue ,fieldText)
- {
- var iChars = "`~!@#$%^*()+=\\-[]';,{}|\":<>?";
- var isPresent = 0;
- for (var i = 0; i < fieldValue.length; i++)
- {
- if (iChars.indexOf(fieldValue.charAt(i)) != -1)
- {
- alert (fieldText + " could not contain special charecters");
- //return false;
- isPresent=1;
- break;
- }
- }
- return isPresent
- }
- /*
- function StringLength(fieldvalue , fieldtext,length)
- Description: This function is used to check the length of a string.
- */
- function StringLength(fieldvalue,fieldtext,length)
- {
- //alert(Trim(fieldvalue).length)
- if((Trim(fieldvalue).length) > length)
- {
- alert(fieldtext + " should be less than or equal to "+ length +" characters");
- return 1; // to indicate in the calling function that error has occurred.
- }
- return 0;
- }
- /*
- function IsNumbFirst(fieldValue,fieldText)
- Description: Is used to check whether there is a number in a string at first position
- */
- function IsNumbFirst(fieldValue,fieldText)
- {
- // var numaric = alphane;
- // var alphaa = numaric.charAt(j);
- var firstChar = fieldValue.charCodeAt(0);
- if(hh > 47 && hh<58)
- {
- alert(fieldText + "should not contain numeric charecter at first position")
- return 1;
- }
- else
- {
- return 0;
- }
- }
- /*
- function ContainsNumber(temp ,FieldText)
- Description: This Function checks if string contains numbers
- */
- function ContainsNumber(fieldValue ,FieldText)
- {
- if (FieldValue.search("0")!= -1||FieldValue.search("1")!= -1 || FieldValue.search("2")!= -1|| FieldValue.search("3")!= -1 ||FieldValue.search("4")!= -1|| FieldValue.search("5")!= -1|| FieldValue.search("6")!= -1|| FieldValue.search("7")!= -1|| FieldValue.search("8")!= -1|| FieldValue.search("9")!= -1 )
- {
- alert( "Numbers Not Allowed In " + FieldText )
- return 1;
- }
- return 0;
- }
- function IsNumb (fieldValue , fieldText )
- {
- if ( isNaN(fieldValue)== true)
- {
- alert(fieldText +" has to be numeric")
- return 1
- }
- return 0;
- }
- /*
- function IsNumb1 (fieldValue , fieldText )
- Description: Is used to check for numeric values
- */
- function IsNumb1 (fieldValue , fieldText )
- {
- if ( isNaN(fieldValue)== false)
- {
- alert(fieldText +" should not be Number")
- return 1
- }
- return 0;
- }
- /*
- function goback()
- Description: Is used to navigate back by one page
- */
- function goback()
- {
- window.history.go(-1)
- }
- /*
- function AlphaNumeric(alphane)
- Description: Is used to validate Alphanumeric value
- */
- function AlphaNumeric(alphane)
- {
- var numeric = alphane;
- for(var j=0; j<numeric.length; j++)
- {
- var alphaa = numeric.charAt(j);
- var hh = alphaa.charCodeAt(0);
- if((hh > 47 && hh<59) || (hh > 64 && hh<91) || (hh > 96 && hh<123))
- {
- }
- else {
- return false;
- }
- }
- return true;
- }
- /*
- function Trim(str)
- Description: Is used to trim the given value
- */
- function Trim(str)
- {
- if (str == null )
- {
- return ""
- }
- var first =0
- while(str.charAt(first)==" ")
- {
- first++
- }
- //alert(first)
- var last=str.length
- //alert(last)
- if(first==last)
- {
- return ""
- }
- while(str.charAt(last-1)==" ")
- {
- last--
- }
- //alert(last)
- return str.substring(first,last)
- //f.DepartmentName.value=f.DepartmentName.value.substring(first,last)
- }
- /*
- function ToProperCase(s)
- Description: Is used to convert a string into a proper case string
- */
- function ToProperCase(s)
- {
- return s.toLowerCase().replace(/^(.)|\s(.)/g,
- function($1) { return $1.toUpperCase(); });
- }
- /*
- function EmailCheck(str)
- Description: Is used to check whether string is a email id
- */
- function EmailCheck(str) {
- var at="@"
- var dot="."
- var lat=str.indexOf(at)
- var lstr=str.length
- var ldot=str.indexOf(dot)
- if (str.indexOf(at)==-1){
- alert("Invalid E-mail ID")
- return true
- }
- if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
- alert("Invalid E-mail ID")
- return true
- }
- if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
- alert("Invalid E-mail ID")
- return true
- }
- if (str.indexOf(at,(lat+1))!=-1){
- alert("Invalid E-mail ID")
- return true
- }
- if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
- alert("Invalid E-mail ID")
- return true
- }
- if (str.indexOf(dot,(lat+2))==-1){
- alert("Invalid E-mail ID")
- return true
- }
- if (str.indexOf(" ")!=-1){
- alert("Invalid E-mail ID")
- return true
- }
- return false
- }
- /*
- function ProperCase(str)
- Description: Is used to convert a string to a proper case string
- */
- function ProperCase(str)
- {
- var arr,str_ret
- str_ret=""
- str=str.toLowerCase()
- arr=str.split(" ")
- for(var i=0;i<arr.length;i++)
- {
- if(arr[i]!="")
- str_ret=str_ret+arr[i].replace(arr[i].charAt(0),arr[i].charAt(0).toUpperCase())+" "
- }
- return str_ret;
- }
- /*
- function Lengthcheck(fieldvalue, fieldText, reqlength)
- Description: This function is used to check the length of a string.
- */
- function Lengthcheck(fieldvalue, fieldText, reqlength)
- {
- if (fieldvalue.length > reqlength)
- {
- alert(fieldText + " should be less than or equal to "+ reqlength +" characters")
- return 1;
- }
- return 0;
- }
- function fonclick()
- {
- var f=document.forms[0];
- f.onClick();
- }
- /*
- function DateCheck(startdate,enddate,FieldText,FieldText1)
- Description: This Function checks if start date is greater than end date
- */
- function DateCheck(startdate,enddate,FieldText,FieldText1)
- {
- var tmp = startdate.split("/",3);
- // var allocDat = new Date(tmp);
- var allocDat=tmp[1]+"/"+tmp[0]+"/"+tmp[2]
- //alert(tmp[1])
- //alert(tmp[0])
- //alert(tmp[2])
- var stdt=Date.parse(allocDat)
- // alert(stdt+"stdt")
- var tmp1 = enddate.split("/",3);
- var dueDat = tmp1[1]+"/"+tmp1[0]+"/"+tmp1[2];
- //alert(tmp1[1])
- //alert(tmp1[0])
- //alert(tmp1[2])
- var eddt=Date.parse(dueDat)
- //alert(eddt+"eddt")
- if(eddt < stdt)
- {
- alert(FieldText + " can not be greater than"+ FieldText1);
- return 1;
- }
- return 0;
- }
- /*
- function StartDateCheck(startdate,FieldText)
- Description: This Function checks if start date is less than equal to current date
- */
- function StartDateCheck(startdate,FieldText)
- {
- //alert(startdate)
- var tmp = startdate.split("/",3)
- var w=tmp[1]+"/"+tmp[0]+"/"+tmp[2]
- var q = Date.parse(w)
- var today=new Date()
- var x=today.getUTCDate()
- var y=today.getUTCMonth()
- y=y+1
- var z=today.getUTCFullYear()
- var t= y+"/"+x+"/"+z
- var l=Date.parse(t)
- if(q < l)
- {
- //alert("inside lezss")
- alert(FieldText +" cannot be less than Current Date");
- return 1;
- }
- return 0;
- }
- /*
- function PrintPage()
- Description: This Function is used to print a Form
- */
- function PrintPage()
- {
- window.print()
- }
- ////////abhi
- function StartDateCheckForGreat1(startdate,FieldText)
- {
- var tmp = startdate.split("/",3)
- if(tmp[1]="Jan")
- {
- tmp[1]=1
- }
- if(tmp[1]="Feb")
- {
- tmp[1]=2
- }
- if(tmp[1]="Mar")
- {
- tmp[1]=3
- }
- if(tmp[1]="Apr")
- {
- tmp[1]=4
- }
- if(tmp[1]="May")
- {
- tmp[1]=5
- }
- if(tmp[1]="Jun")
- {
- tmp[1]=6
- }
- if(tmp[1]="Jul")
- {
- tmp[1]=7
- }
- if(tmp[1]="Aug")
- {
- tmp[1]=8
- }
- if(tmp[1]="Sep")
- {
- tmp[1]=9
- }
- if(tmp[1]="Oct")
- {
- tmp[1]=10
- }
- if(tmp[1]="Nov")
- {
- tmp[1]=11
- }
- if(tmp[1]="Dec")
- {
- tmp[1]=12
- }
- /////abhi
- var w=tmp[1]+"/ "+tmp[0]+"/ "+tmp[2]
- var q = Date.parse(w)
- // q.toLocaleString()
- var today=new Date()
- var x=today.getUTCDate()
- var y=today.getUTCMonth()
- y=y+1
- var z=today.getUTCFullYear()
- var t= y+" /"+x+"/ "+z
- var l=Date.parse(t)
- // l.toLocaleString()
- if(q > l)
- {
- alert(FieldText +" cannot be greater than Current Date");
- return 1;
- }
- return 0;
- }
- /////abhi ends
- /*
- function DisableField(webForm,fieldDet)
- Description: This Function is used to disable all fields on a Form
- */
- function DisableField(webForm,disFieldDet)
- {
- for(var i=0;i<disFieldDet.length;i++)
- {
- if(disFieldDet[i][0]==1)
- {
- eval("webForm."+disFieldDet[i][1]+".readOnly=true")
- }
- else if(disFieldDet[i][0]==2)
- {
- eval("webForm."+disFieldDet[i][1]+".disabled=true")
- }
- else if(disFieldDet[i][0]==3)
- {
- for(var j=0;j<disFieldDet[i][2];j++)
- {
- eval("webForm."+disFieldDet[i][1]+"["+j+"].disabled=true")
- //alert("webForm."+disFieldDet[i][1])
- //alert(j)
- }
- }
- }
- }
- /*
- function EnableField(webForm,fieldDet)
- Description: This Function is used to enable all fields on a Form
- */
- function EnableField(webForm,disFieldDet)
- {
- for(var i=0;i<disFieldDet.length;i++)
- {
- if(disFieldDet[i][0]==1)
- {
- eval("webForm."+disFieldDet[i][1]+".readOnly=false")
- }
- else if(disFieldDet[i][0]==2)
- {
- eval("webForm."+disFieldDet[i][1]+".disabled=false")
- }
- else if(disFieldDet[i][0]==3)
- {
- for(var j=0;j<disFieldDet[i][2];j++)
- {
- eval("webForm."+disFieldDet[i][1]+"["+j+"].disabled=false")
- }
- }
- }
- }
- function ShowSaveButton()
- {
- var saveNClose = document.getElementById("saveNClose");
- var editDocument = document.getElementById("editDocument");
- saveNClose.style.display=''
- editDocument.style.display='none'
- }
- function dateDifference(fieldvalue,fieldvalue)
- {
- var f = document.forms(0)
- var date1=new Date(f.date_1.value)
- var date2 = new Date(f.date_2.value)
- var one_day=1000*60*60*24
- f.noofdate.value=(Math.ceil((date1.getTime()-date2.getTime())/(one_day))+1+
- " Days difference");
- return true
- }
- function checkfilename()
- {
- var form=document.forms(0)
- var allfields=form.elements.length
- alert(allfields)
- var fieldtype
- var fieldvalue
- for(i=0;i<allfields;i++)
- {
- fieldtype=form.elements[i].type
- //alert(fieldtype)
- fieldvalue=form.elements[i].value
- //alert(fieldvalue)
- if(fieldtype=="file")
- break
- }
- // check for blank file path
- if(fieldvalue=="")
- {
- alert("Please select file")
- return false
- }
- else
- {
- // check for bad characters in file path
- var start=fieldvalue.lastIndexOf("\\")+1
- end=fieldvalue.length
- var filename=fieldvalue.slice(start,end)
- var badchars=" !"+'"'+"£$%^&*()+'/\?,@`|¬"
- var check
- for(c=0;c<badchars.length;c++)
- {
- check=filename.indexOf(badchars.substring(c,c+1))
- if(check != -1)
- {
- alert("Not a valid file name."+check)
- return false
- }
- }
- }
- return true
- }
- /*
- Function SetFieldValues(webForm,fieldName)
- Description : Sets the lookup value in individual fields in the given order
- */
- function SetFieldValues(webForm,fieldNames,lkpFieldName)
- {
- var lkpFieldValue=new Array()
- lkpFieldValue=webForm[lkpFieldName].value.split("!#")
- for(var i=0;i<fieldNames.length;i++)
- {
- webForm[fieldNames[i]].value=lkpFieldValue[i]
- }
- }
- /*
- function Validate(webForm,fieldDet)
- fieldDet: fieldName,fieldPrompt,Option,extras
- Option :
- IsBlank
- IsNumbFirst
- IsNumb
- IsNotNumb
- ContainsNumber
- IsBlankForList
- LengthCheck : strlen
- EmailCheck
- StringLength : strlen
- StartDateCheckGreat
- DateCheck : enddate field name
- StartDateCheckLess
- CheckFileName
- AlphaNumeric
- ContainsSpecialChar
- UniqueCheck : lookup field name
- */
- //function Validate(webForm,FieldDet)
- function Validate(webForm,fieldDet)
- {
- for(var i=0;i<fieldDet.length;i++)
- {
- // alert(alert(fieldDet[i][0])+" - "+fieldDet[i][2]);
- switch(fieldDet[i][2])
- {
- /*
- IsBlank (fieldvalue, fieldtext)
- Description: Is used to validate field for blank values
- */
- case "IsBlank":
- if(Trim(webForm[fieldDet[i][0]].value)=="" || Trim(webForm[fieldDet[i][0]].value)=="----Select----")
- {
- alert("Please Enter "+ fieldDet[i][1]);
- webForm[fieldDet[i][0]].focus();
- return 1;
- }
- break
- /*
- IsBlankForSelection (fieldvalue, fieldtext)
- Description: Is used to validate field for blank values
- */
- case "IsBlankForSelection":
- if(Trim(webForm[fieldDet[i][0]].value)=="" || Trim(webForm[fieldDet[i][0]].value)=="----Select----")
- {
- alert("Please Select "+ fieldDet[i][1]);
- webForm[fieldDet[i][0]].focus();
- return 1;
- }
- break
- /*
- IsBlankForSection (fieldvalue, fieldtext)
- Description: Is used to validate field for blank values (those field under hidden section)
- */
- case "IsBlankForSection":
- if(Trim(webForm[fieldDet[i][0]].value)=="" || Trim(webForm[fieldDet[i][0]].value)=="----Select----")
- {
- alert("Please Enter "+ fieldDet[i][1]);
- //webForm[fieldDet[i][0]].focus();
- return 1;
- }
- break
- /*
- IsNumbFirst(fieldValue,fieldText)
- Description: Is used to check whether there is a number in a string at first position
- */
- case "IsNumbFirst":
- var firstChar = webForm[fieldDet[i][0]].value.charCodeAt(0);
- if(firstChar > 47 && firstChar<58)
- {
- alert(fieldDet[i][1] + " should not contain numeric character at first position")
- webForm[fieldDet[i][0]].value="";
- webForm[fieldDet[i][0]].focus();
- return 1;
- }
- break
- /*
- function IsNumb (fieldValue , fieldText )
- Description: Is used to check for numeric values
- */
- case "IsNumb":
- if ( isNaN(webForm[fieldDet[i][0]].value)== true)
- {
- alert(fieldDet[i][1] +" should be Number")
- webForm[fieldDet[i][0]].value="";
- webForm[fieldDet[i][0]].focus();
- return 1
- }
- break
- /*
- function IsNotNumb (fieldValue , fieldText )
- Description: Is used to check for numeric values
- */
- case "IsNotNumb":
- if ( isNaN(webForm[fieldDet[i][0]].value)== false)
- {
- alert(fieldDet[i][1] +" should not be Number")
- webForm[fieldDet[i][0]].value="";
- webForm[fieldDet[i][0]].focus();
- return 1
- }
- break
- /*
- function ContainsNumber(temp ,FieldText)
- Description: This Function checks if string contains numbers
- */
- case "ContainsNumber":
- if (webForm[fieldDet[i][0]].value.search("0")!= -1||webForm[fieldDet[i][0]].value.search("1")!= -1 || webForm[fieldDet[i][0]].value.search("2")!= -1|| webForm[fieldDet[i][0]].value.search("3")!= -1 || webForm[fieldDet[i][0]].value.search("4")!= -1|| webForm[fieldDet[i][0]].value.search("5")!= -1|| webForm[fieldDet[i][0]].value.search("6")!= -1|| webForm[fieldDet[i][0]].value.search("7")!= -1|| webForm[fieldDet[i][0]].value.search("8")!= -1|| webForm[fieldDet[i][0]].value.search("9")!= -1 )
- {
- alert( "Numbers Not Allowed In " + fieldDet[i][1])
- webForm[fieldDet[i][0]].value="";
- webForm[fieldDet[i][0]].focus();
- return 1;
- }
- break
- /*
- function IsBlankForList (fieldvalue ,fieldtext)
- Description: Is used to check for blank value for drop down fields
- */
- case "IsBlankForList":
- var fieldVal=webForm[fieldDet[i][0]]
- if(fieldVal.options[fieldVal.selectedIndex].text=="" || fieldVal.options[fieldVal.selectedIndex].text=="----- Please Select -----")
- {
- alert("Please Select "+ fieldDet[i][1])
- webForm[fieldDet[i][0]].focus();
- return 1;
- }
- break
- /*checks if the entered data is TEXT ONLY not number or special char or blank (sam)*/
- case "textOnly":
- var fieldVal=webForm[fieldDet[i][0]]
- if(fieldVal.value.match("[^A-Za-z ]" ))
- {
- alert("The values in this field "+fieldDet[i][1]+ " should be alphabetic only")
- webForm[fieldDet[i][0]].value="";
- webForm[fieldDet[i][0]].focus();
- return 1;
- }
- break
- ////////////////////////////////////////
- /* validation for radio button (sam)*/
- case "radioVal":
- var fieldVal=webForm[fieldDet[i][0]]
- var cnt = -1;
- for (var j=fieldVal.length-1; j > -1; j--)
- {
- if (fieldVal[j].checked)
- {
- cnt = j;
- j = -1;
- } //if
- } //for
- if (cnt == -1)
- {
- alert("Please Select "+fieldDet[i][1])
- //webForm[fieldDet[i][0]].focus();
- return 1;
- //alert("2");
- }
- //alert("3");
- break
- //////////////////////////////////////////////////////////
- /*
- function Lengthcheck(fieldvalue, fieldText, reqlength)
- Description: This function is used to check the length of a string.
- */
- case "Lengthcheck":
- if (webForm[fieldDet[i][0]].value.length > fieldDet[i][3])
- {
- alert(fieldDet[i][1] + " should be less than or equal to "+ fieldDet[i][3] +" characters")
- webForm[fieldDet[i][0]].value="";
- webForm[fieldDet[i][0]].focus();
- return 1;
- }
- break
- /*
- function EmailCheck(str)
- Description: Is used to check whether string is a email id
- */
- case "EmailCheck":
- var at="@"
- var dot="."
- var lat=webForm[fieldDet[i][0]].value.indexOf(at)
- var lstr=webForm[fieldDet[i][0]].value.length
- var ldot=webForm[fieldDet[i][0]].value.indexOf(dot)
- if (webForm[fieldDet[i][0]].value.indexOf(at)==-1)
- {
- alert("Please Enter valid " + fieldDet[i][1])
- webForm[fieldDet[i][0]].value="";
- webForm[fieldDet[i][0]].focus();
- return 1;
- }
- if (webForm[fieldDet[i][0]].value.indexOf(at)==-1 || webForm[fieldDet[i][0]].value.indexOf(at)==0 || webForm[fieldDet[i][0]].value.indexOf(at)==lstr)
- {
- alert("Please Enter valid " + fieldDet[i][1])
- webForm[fieldDet[i][0]].value="";
- webForm[fieldDet[i][0]].focus();
- return 1;
- }
- if (webForm[fieldDet[i][0]].value.indexOf(dot)==-1 || webForm[fieldDet[i][0]].value.indexOf(dot)==0 || webForm[fieldDet[i][0]].value.indexOf(dot)==lstr)
- {
- alert("Please Enter valid " + fieldDet[i][1])
- webForm[fieldDet[i][0]].value="";
- webForm[fieldDet[i][0]].focus();
- return 1;
- }
- if (webForm[fieldDet[i][0]].value.indexOf(at,(lat+1))!=-1)
- {
- alert("Please Enter valid " + fieldDet[i][1])
- webForm[fieldDet[i][0]].value="";
- webForm[fieldDet[i][0]].focus();
- return 1;
- }
- if (webForm[fieldDet[i][0]].value.substring(lat-1,lat)==dot || webForm[fieldDet[i][0]].value.substring(lat+1,lat+2)==dot)
- {
- alert("Please Enter valid " + fieldDet[i][1])
- webForm[fieldDet[i][0]].value="";
- webForm[fieldDet[i][0]].focus();
- return 1;
- }
- if (webForm[fieldDet[i][0]].value.indexOf(dot,(lat+2))==-1)
- {
- alert("Please Enter valid " + fieldDet[i][1])
- webForm[fieldDet[i][0]].value="";
- webForm[fieldDet[i][0]].focus();
- return 1;
- }
- if (webForm[fieldDet[i][0]].value.indexOf(" ")!=-1)
- {
- alert("Please Enter valid " + fieldDet[i][1])
- webForm[fieldDet[i][0]].value="";
- webForm[fieldDet[i][0]].focus();
- return 1;
- }
- break
- /*
- function StringLength(fieldvalue , fieldtext,length)
- Description: This function is used to check the length of a string.
- */
- case "StringLength":
- // alert(webForm[fieldDet[i][0]].value.length)
- if((Trim(webForm[fieldDet[i][0]].value).length) > fieldDet[i][3])
- {
- // alert(webForm[fieldDet[i][0]].value.length)
- alert(fieldDet[i][1] + " should be less than or equal to "+ fieldDet[i][3] +" characters");
- webForm[fieldDet[i][0]].value="";
- webForm[fieldDet[i][0]].focus();
- return 1; // to indicate in the calling function that error has occurred.
- }
- break
- /*
- function StartDateCheckGreat(startdate,FieldText)
- Description: This Function checks if start date is less than equal to current date
- */
- case "StartDateCheckGreat":
- var dateVal = webForm[fieldDet[i][0]].value.split("/",3)
- var dateStr=dateVal[1]+"/"+dateVal[0]+"/"+dateVal[2]
- var tmpDate = Date.parse(dateStr)
- var today=new Date()
- var dd=today.getUTCDate()
- var mm=today.getUTCMonth()
- mm=mm+1
- var yy=today.getUTCFullYear()
- var todayStr= mm+"/"+dd+"/"+yy
- var todayDate=Date.parse(todayStr)
- if(tmpDate < todayDate)
- {
- alert(Field[i][1] + " should be less than Current Date");
- webForm[fieldDet[i][0]].value="";
- webForm[fieldDet[i][0]].focus();
- return 1;
- }
- break
- /*
- function DateCheck(startdate,enddate,FieldText,FieldText1)
- Description: This Function checks if start date is greater than end date
- */
- case "DateCheck":
- var startDateVal = webForm[fieldDet[i][0]].value.split("/",3);
- var startDateStr=startDateVal[1]+"/"+startDateVal[0]+"/"+startDateVal[2]
- var startDate=Date.parse(startDateStr)
- var endDateVal = webForm[fieldDet[i][3]].value.split("/",3);
- var endDateStr = endDateVal[1]+"/"+endDateVal[0]+"/"+endDateVal[2];
- var endDate=Date.parse(endDateStr)
- if(endDate < startDate)
- {
- alert(fieldDet[i][1] + " can not be greater than End Date" ); //" + fieldDet[i][3]
- webForm[fieldDet[i][3]].value="";
- webForm[fieldDet[i][3]].focus();
- return 1;
- }
- /*
- function dateDifference(fieldvalue,fieldvalue)
- {
- var date1=new Date(form.date_1.value)
- var date2 = new Date(f.date_2.value)
- var one_day=1000*60*60*24
- f.noofdate.value=(Math.ceil((date1.getTime()-date2.getTime())/(one_day))+1+
- " Days difference");
- return true
- }
- */
- break
- /*
- function StartDateCheckForGreat(startdate,FieldText)
- Description: This Function checks if start date is greater than equal than current date
- */
- case "StartDateCheckLess":
- var dateVal = webForm[fieldDet[i][0]].value.split("/",3)
- var dateStr=dateVal[1]+"/"+dateVal[0]+"/"+dateVal[2]
- var tmpDate = Date.parse(dateStr)
- var today=new Date()
- var dd=today.getUTCDate()
- var mm=today.getUTCMonth()
- mm=mm+1
- var yy=today.getUTCFullYear()
- var todayStr= mm+"/"+dd+"/"+yy
- var todayDate =Date.parse(todayStr)
- if( tmpDate > todayDate)
- {
- alert( fieldDet[i][0]+ " should be greater than Current Date");
- webForm[fieldDet[i][0]].value="";
- webForm[fieldDet[i][0]].focus();
- return 1;
- }
- break
- case "StartDateCheckHigh":
- var dateVal = webForm[fieldDet[i][0]].value.split("/",3)
- var dateStr=dateVal[1]+"/"+dateVal[0]+"/"+dateVal[2]
- var tmpDate = Date.parse(dateStr)
- var today=new Date()
- var dd=today.getUTCDate()
- var mm=today.getUTCMonth()
- mm=mm+1
- var yy=today.getUTCFullYear()
- var todayStr= mm+"/"+dd+"/"+yy
- var todayDate =Date.parse(todayStr)
- if( tmpDate < todayDate)
- {
- alert( fieldDet[i][1]+ " should not be less than Current Date");
- webForm[fieldDet[i][0]].value="";
- webForm[fieldDet[i][0]].focus();
- return 1;
- }
- break
- case "CheckFileName":
- function checkfilename()
- {
- var allfields=webForm.elements.length
- //alert(allfields)
- var fieldtype
- var fieldvalue
- for(i=0;i<allfields;i++)
- {
- fieldtype=webForm.elements[i].type
- //alert(fieldtype)
- fieldvalue=webForm.elements[i].value
- //alert(fieldvalue)
- if(fieldtype=="file")
- break
- }
- // check for blank file path
- if(fieldvalue=="")
- {
- alert("Please select file")
- return false
- }
- else
- {
- // check for bad characters in file path
- var start=fieldvalue.lastIndexOf("\\")+1
- end=fieldvalue.length
- var filename=fieldvalue.slice(start,end)
- var badchars=" !"+'"'+"£$%^&*()+'/\?,@`|¬"
- var check
- for(c=0;c<badchars.length;c++)
- {
- check=filename.indexOf(badchars.substring(c,c+1))
- if(check != -1)
- {
- alert("Not a valid file name."+check)
- return false
- }
- }
- }
- return true
- }
- break
- /*
- function ContainsSpecialChar(str)
- Description: Is used to check whether string contains a special charecter
- */
- case "ContainsSpecialChar":
- var iChars = "`~!@#$%^*()+=\\[]';,{}|\":<>?";
- var isPresent = 0;
- // alert("function sp chars")
- //var temp=
- //alert(temp.length)
- for (var j = 0; j < webForm[fieldDet[i][0]].value.length; j++)
- {
- // alert(webForm[fieldDet[i][0]].value)
- if (iChars.indexOf(webForm[fieldDet[i][0]].value.charAt(j)) != -1)
- {
- alert (fieldDet[i][1] + " could not contain special characters");
- webForm[fieldDet[i][0]].value="";
- webForm[fieldDet[i][0]].focus();
- return 1
- }
- }
- break
- /*
- function AlphaNumeric(alphane)
- Description: Is used to validate Alphanumeric value
- */
- case "AlphaNumeric":
- var numeric = webForm[fieldDet[i][0]].value;
- for(var j=0; j<numeric.length; j++)
- {
- var alphaa = numeric.charAt(j);
- var hh = alphaa.charCodeAt(0);
- if((hh > 47 && hh<59) || (hh > 64 && hh<91) || (hh > 96 && hh<123))
- {
- alert("Please Enter Alpha Numeric Value in "+ fieldDet[i][1] )
- webForm[fieldDet[i][0]].value="";
- webForm[fieldDet[i][0]].focus();
- return 1
- }
- }
- break
- /*
- function UniqueCheck (fieldvalue, fieldtext ,valueList)
- Description : Is used to check uniqueness of thye entry
- */
- case "UniqueCheck":
- var length,temp
- var i,exist
- var arr=new Array();
- arr = webForm[fieldDet[i][3]].value.split(", ")
- length = arr.length
- if(webForm[fieldDet[i][0]].type=="select-one")
- {
- temp=Trim(webForm[fieldDet[i][0]].options[webForm[fieldDet[i][0]].selectedIndex].text)
- }
- else
- {
- temp=Trim(webForm[fieldDet[i][0]].value)
- }
- for(j=0;j<length;j++)
- {
- if(Trim(temp.toLowerCase())==Trim(arr[j].toLowerCase()))
- {
- alert(fieldDet[i][1]+" \""+temp+"\" Already Exists")
- webForm[fieldDet[i][0]].value="";
- webForm[fieldDet[i][0]].focus();
- return 1;
- }
- }
- break
- case "UniqueCheckForSingleDOC":
- if(webForm[fieldDet[i][0]].value!="" )
- {
- alert(fieldDet[i][1] + " Should Contain Single Document")
- return 1
- }
- break
- } // end of switch loop
- } // end of for loop
- return 0;
- } // end of validate function
- function IsBlankForDialogList(fieldValue , fieldText )
- {
- if(webForm.dlNetworkDomain.selectedIndex==-1)
- {
- alert("Please select " + fieldText)
- return 1
- }
- return 0;
- }
- function BuildSummaryTable(webForm,fieldName,SummaryTableId)
- {
- var actTakenOn=new Array()
- var userName=new Array()
- actTakenOn = webForm[fieldName[0]].value.split("!#")
- userName = webForm[fieldName[1]].value.split("!#")
- for(i=1;i<actTakenOn.length;i++)
- {
- var row=document.getElementById(SummaryTableId).insertRow(-1)
- var actTakenOnCell=row.insertCell(-1)
- var userNameCell=row.insertCell(-1)
- actTakenOnCell.className="DynamicTableRevokeCell"
- actTakenOnCell.innerHTML=actTakenOn[i]
- actTakenOnCell.width= 50
- userNameCell.width=150
- userNameCell.className="DynamicTableRevokeCell"
- userNameCell.innerHTML=(userName[i])
- }
- }
- //----------For CheckBox disabled & Checked-------------------
- function readOnlyCheckBox()
- {
- return false;
- }
- function validateFileupload(fileid)
- {
- var Fileval= document.getElementById(fileid).value
- var Slash = "\\";
- if((Fileval.substring(0,1)!="" &&Fileval.substring(1,2)==":" &&Fileval.substring(2,3)==Slash .substring(0,1))|| Fileval=="")
- {
- return 0
- }
- else
- {
- return 1
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement