Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64
Your IP : 18.119.124.24
// position should be < 0
function tarkaRound(number,position)
{
var zeors = 1;
for(var i =1; i<=position; i++)
{
zeors = zeors * 10 ;
}
return Math.round(number*zeors)/zeors;
}
// Trim the given String
function trim($str)
{
return jQuery.trim($str);
}
function validateemail(evt,emailid)
{
var atpos = emailid.indexOf("@");
var dotpos = emailid.lastIndexOf(".");
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=emailid.length)
return false;
else
return true;
}
function validatewebsite(evt,website)
{
if (empty($_POST["website"]))
{
$website = "";
}
else
{
$website = test_input($_POST["website"]);
}
// check if URL address syntax is valid (this regular expression also allows dashes in the URL)
if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i",$website))
{
$websiteErr = "Invalid URL";
}
}
function acceptNumbersOnlyForModule(evt)
{
var charCode = (evt.which) ? evt.which : evt.keyCode;
if (charCode > 41 && (charCode < 46 || charCode > 57) && charCode!=46)
return false;
return true;
}
function acceptNumbersSign(evt)
{
var charCode = (evt.which) ? evt.which : evt.keyCode;
if (charCode > 41 && (charCode < 45 || charCode > 57) && charCode!=45)
return false;
return true;
}
function acceptNumbersOnlyForModuleABMP(evt)
{
var charCode = (evt.which) ? evt.which : evt.keyCode;
if (charCode > 41 && (charCode < 46 || charCode > 57) && charCode!=97 && charCode!=78 && charCode!=110 && charCode!=112&& charCode!=109&& charCode!=98 && charCode!=47 && charCode!=80 && charCode!=77 && charCode!=66 && charCode!=69 && charCode!=101 && charCode!=65 && charCode!=99 && charCode!=118 && charCode!=120 || charCode==32 )
return false;
return true;
}
function AcceptNumbersOnly(evt)
{
var charCode = (evt.which) ? evt.which : evt.keyCode;
/* if (charCode > 41 && (charCode < 45 || charCode > 57) && charCode!=47 && charCode!=99 && charCode!=118 && charCode!=120 && charCode!=78 && charCode!=65
&& charCode!=97 && charCode!=110 && charCode!=77 && charCode!=80 && charCode!=109 && charCode!=112 )
*/
if (charCode > 41 && (charCode < 48 || charCode > 57) && charCode!=46 || charCode == 190)
return false;
return true;
}
function validateDate(ldate)
{
var pattern = /^([0-9]{2})\/([0-9]{2})\/([0-9]{4})$/;
if (ldate == null || ldate == "" || !pattern.test(ldate)) {
errMessage = "Invalid date\n";
alert(errMessage);
return errMessage;
}
else
{
var matchArray = ldate;
var day = matchArray.substring(0,2);
var month = matchArray.substring(3,5);
var year = matchArray.substring(6,10);
if (month < 1 || month > 12)
{
alert("Month must be between 1 and 12.");
return false;
}
if (day < 1 || day > 31)
{
alert("Day must be between 1 and 31.");
return false;
}
return 999;
}
}
function validateTime(time)
{
var check =/^([0-9]{0,2})([\:]{1,1})([0-9]{0,2})$/;
if (time.match(check))
return true;
else
return false;
}
function validnumberold(no)
{
var dateRE = /^([0-9]{0,10})([\.]{0,1})([0-9]{0,9})$/;
if (no.match(dateRE))
return true;
else
return false;
}
function validnumber(no)
{
var dateRE = /^([0-9]{0,10})([\.]{0,1})([0-9]{0,9})$/;
if (no.match(dateRE))
return true;
else
return false;
}
function isNumber(no)
{
var dateRE = /^([0-9.])*$/;
return true;
if (no.match(dateRE))
return true;
else
return false;
}
//Accept charecters and space
function charKeydown(){
var ch = String.fromCharCode(event.keyCode);
var filter = /[a-zA-Z ]/;
if(!filter.test(ch)){
event.returnValue = false;
}
}
function isLetter(no)
{
var dateRE = /^[a-zA-Z-,]+(\s{0,1}[a-zA-Z-, ])*$/;
if (no.match(dateRE))
return true;
else
return false;
}
function validDecimal(no,$dec)
{
var dateRE=new RegExp("\^([\-]{0,1})([0-9]{0,10})([\.]{0,1})([0-9]{0,"+$dec+"})$");
if (no.match(dateRE))
return true;
else
return false;
}
function roundNumber(number,decimal_points)
{
if(!decimal_points) return Math.round(number);
if(number == 0) {
var decimals = "";
for(var i=0;i<decimal_points;i++) decimals += "0";
return "0."+decimals;
}
var exponent = Math.pow(10,decimal_points);
var num = Math.round((number * exponent)).toString();
return num.slice(0,-1*decimal_points) + "." + num.slice(-1*decimal_points);
}
function phpround (value, precision, mode) {
// Returns the number rounded to specified precision
//
// version: 1107.2516
// discuss at: http://phpjs.org/functions/round // + original by: Philip Peterson
// + revised by: Onno Marsman
// + input by: Greenseed
// + revised by: T.Wild
// + input by: meo // + input by: William
// + bugfixed by: Brett Zamir (http://brett-zamir.me)
// + input by: Josep Sanz (http://www.ws3.es/)
// + revised by: Rafal Kukawski (http://blog.kukawski.pl/)
// % note 1: Great work. Ideas for improvement: // % note 1: - code more compliant with developer guidelines
// % note 1: - for implementing PHP constant arguments look at
// % note 1: the pathinfo() function, it offers the greatest
// % note 1: flexibility & compatibility possible
// * example 1: round(1241757, -3); // * returns 1: 1242000
// * example 2: round(3.6);
// * returns 2: 4
// * example 3: round(2.835, 2);
// * returns 3: 2.84 // * example 4: round(1.1749999999999, 2);
// * returns 4: 1.17
// * example 5: round(58551.799999999996, 2);
// * returns 5: 58551.8
var m, f, isHalf, sgn; // helper variables precision |= 0; // making sure precision is integer
m = Math.pow(10, precision);
value *= m;
sgn = (value > 0) | -(value < 0); // sign of the number
isHalf = value % 1 === 0.5 * sgn; f = Math.floor(value);
if (isHalf) {
switch (mode) {
case 'PHP_ROUND_HALF_DOWN': value = f + (sgn < 0); // rounds .5 toward zero
break;
case 'PHP_ROUND_HALF_EVEN':
value = f + (f % 2 * sgn); // rouds .5 towards the next even integer
break; case 'PHP_ROUND_HALF_ODD':
value = f + !(f % 2); // rounds .5 towards the next odd integer
break;
default:
value = f + (sgn > 0); // rounds .5 away from zero }
}
return (isHalf ? value : Math.round(value)) / m;
}
}
function to_upperx(id)
{
var x = document.getElementById(id).value;
document.getElementById(id).value = x.toUpperCase();
}
var dtCh= "/";
var minYear=1900;
var maxYear=2100;
function isInteger(s){
var i;
for (i = 0; i < s.length; i++){
// Check that current character is number.
var c = s.charAt(i);
if (((c < "0") || (c > "9"))) return false;
}
// All characters are numbers.
return true;
}
function stripCharsInBag(s, bag){
var i;
var returnString = "";
// Search through string's characters one by one.
// If character is not in bag, append to returnString.
for (i = 0; i < s.length; i++){
var c = s.charAt(i);
if (bag.indexOf(c) == -1) returnString += c;
}
return returnString;
}
function daysInFebruary (year){
// February has 29 days in any year evenly divisible by four,
// EXCEPT for centurial years which are not also divisible by 400.
return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
for (var i = 1; i <= n; i++) {
this[i] = 31
if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
if (i==2) {this[i] = 29}
}
return this
}
function isDate(dtStr){
var daysInMonth = DaysArray(12)
var pos1=dtStr.indexOf(dtCh)
var pos2=dtStr.indexOf(dtCh,pos1+1)
var strDay=dtStr.substring(0,pos1)
var strMonth=dtStr.substring(pos1+1,pos2)
var strYear=dtStr.substring(pos2+1)
strYr=strYear
if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
for (var i = 1; i <= 3; i++) {
if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
}
month=parseInt(strMonth)
day=parseInt(strDay)
year=parseInt(strYr)
if (pos1==-1 || pos2==-1){
alert("The date format should be : dd/mm/yyyy")
return false
}
if (strMonth.length<1 || month<1 || month>12){
alert("Please enter a valid month")
return false
}
if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
alert("Please enter a valid day")
return false
}
if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
return false
}
if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
alert("Please enter a valid date")
return false
}
return true
}
//
function dmydateformat(e,id)
{
if (e.keyCode != 8)
{
if ($("#"+id).val().length == 2){
$("#"+id).val($("#"+id).val() + "/");
}else if ($("#"+id).val().length == 5){
$("#"+id).val($("#"+id).val() + "/");
}
}
}
|