Click to See Complete Forum and Search --> : the .value attribute


jlmz
11-30-2002, 03:11 AM
:) Hi

I have a form that on a click, I replicate two textfields:

document.evento2.fecinih.value=document.evento2.fecini.value;
document.evento2.fecfinh.value=document.evento2.fecfin.value;

But my problem is that in those textfields, I'm inserting a date in spanish format:

30/05/2002

Is the value in fecini textfield. Ant when I replicate to the fecinih textfield, it looks all right, but isn't it.

The problem is when I take the value of my fecinih value and I note that this value is NaN (or NaM, something like this)

And to try to manipulate this date, is imposible.

Then, when (sometiemes) I can take the value, the format date change and the Date variable takes the next data:
day = month
month = day

I think this is 'cause the server is on usa, so I have the default format to english date format. but I needed on Spanish format.

Coud anyone help me???

Regards

:confused:

Paco Zarabozo
11-30-2002, 03:28 AM
Nope. Javascript works on client side (it is, on your machine, not on the server).

NaN means Not A Number. I don't know what are you doing exactly on your code, but i can guess you're handling "xx/xx/xx" like if it were a number.

If you need to get dates from "xx/xx/xx", and you need a custom format, you'll need to separate your values as a STRING first.

customDate = "24/12/02";
day = customDate.substring(0, 2);
month = customDate.substring(3, 5);
year = customDate.substring(6, 8);
// Convert values to numeric type
day = int(day);
month = int(month);
year = int(year);

Then, do whatever you need to do with those values. :-)

Hope it helps,
Paco.

jlmz
12-01-2002, 03:22 AM
Thanks 4 u'r reply

I can do this, but I'm trying to get the xx/xx/xxxx value into a Date type var, and I get a NaN.

The value assignament, only works when the user write the data into the text box. When I copy the value on a JavaScript function, I get the NaN error.