struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mamitche...@iba.com.by
Subject Re: VIRUS Warning: AW: Data Object and Calendar
Date Wed, 01 Aug 2001 09:31:06 GMT

Unfortunately discussion software treated my attachment as virus.
I'll put here entrie contents of my function:

var dateDelim = '-';
var dateOrder = 'DMY';
var dateMask = '';
var lastValidatedDate = null;
var requiredMsg = 'Value required for field ';

var invalidMsg = 'Invalid value for field ';function validateDate(item,
label, required) {
  if(required && item.value == '') {
    alert(requiredMsg + '"' + label + '"');
    return false;
  }
  if(item.value == '') return true;
  var expRes = /([0-9]*)([^0-9]([0-9]*)([^0-9]([0-9]
*))?)?/.exec(item.value);
  if(expRes != null) {
    var curDate = new Date();
    var ys = expRes[(dateOrder.indexOf('Y') + 1) * 2 - 1];
    var y = NaN;
    if(ys == '') y = curDate.getFullYear();
    else y = parseInt(ys);
    if(y >= 0 && y <= 99) {
      var y100 = curDate.getFullYear();
      y100 = y100 - (y100 % 100);
      if(y > 50) {
        y += y100 - 100;
      }
      else {
        y += y100;
      }
    }
    var ms = expRes[(dateOrder.indexOf('M') + 1) * 2 - 1];
    var m = NaN;
    if(ms == '') m = curDate.getMonth() + 1;
    else m = parseInt(ms);
    var d = parseInt(expRes[(dateOrder.indexOf('D') + 1) * 2 - 1]);
    var date = new Date(y, m - 1, d);
  }
  if(expRes == null || isNaN(d) || date == null ||
    date.getFullYear() != y || date.getMonth() != (m - 1) ||
    date.getDate() != d) {
    item.focus();
    item.focus();
    alert(invalidMsg + '"' + label + '"');
    return false;
  }
  else {
    var adj = ''
    for(i=0; i<3; i++) {
      if(i > 0) adj += dateDelim;
      switch(dateOrder.charAt(i)) {
        case 'Y': adj += date.getFullYear();
              break;
        case 'M':
              var mm = new String('0' + (date.getMonth() + 1));
              adj += mm.substr(mm.length - 2);
              break;
        case 'D':
              var dd = new String('0' + date.getDate());
              adj += dd.substr(dd.length - 2);
              break;
      }
    }
    item.value = adj;
    lastValidatedDate = adj;
    return true;
  }
}

-----------------------
Andrei Mamitchev
mamitchev@hotmail.com
ICQ#: 89581227

Hi Andrei,
what does this mean:

ScanMail for Microsoft Exchange has detected virus-infected attachment(s).

Sender = mamitchev_a@iba.com.by
Recipient(s) = struts-user@jakarta.apache.org
Subject = Re: Data Object and Calendar
Scanning Time = 08/01/2001 09:54:48

Action on virus found:
The attachment validate.js matched file blocking settings. ScanMail has
Deleted it.

Warning to recipient. ScanMail detected a virus in an email attachment.
08/01/200109:54 AM
[validate.js/Deleted]
Re: Data Object and Calendar
mamitchev_a@iba.com.by

-----Ursprungliche Nachricht-----
Von: mamitchev_a@iba.com.by [mailto:mamitchev_a@iba.com.by]
Gesendet: Mittwoch, 1. August 2001 10:47
An: struts-user@jakarta.apache.org
Betreff: Re: Data Object and Calendar



Matt,

I solved this problem using JavaScript (if Java behaves with the same way,
it will work for Java too). I compared resulting values of day, month and
year for destination date after setting this properties. If they're
different, date is invalid.
I include my JavaScript version here: (See attached file: validate.js)

-----------------------
Andrei Mamitchev
mamitchev@hotmail.com
ICQ#: 89581227

I have a Data Object (DO) that we use to throw b/w our EJBs and forms.

1.  In one particular DO, I am using the Gregorian Calendar to set day,
month
and year.
2.  I am using the validation framework to validate that day is b/w 1-31,
that
month is b/w 1-12 and year is b/w 2001 and 2100.

The validation framework is not validating day or month, because with the
gregorian calendar in my getters/setters - you can set a day or a month to
any
number and it will simply increment the calendar.

Does anyone know of a way to get around this?  I'd like to NOT use
Javascript,
but I want to validate the value the user entered, rather than the value
from
the DO using getValue();




Mime
View raw message