chrometweaks.org

Please tell me about free iPage web hosting?

Click Here To View All Answers...


First question I got is Please tell me about free iPage web hosting? Many thanks for any answer or 2. Another question I got... I'm having a bad hair day (having no hair that's quite impressive!).

I can't seem to recall or work out how to do any number of things so if anyone can help I pormise to lavish them with gifts and praise..

1. How do you prevent a user from pressing Return to submit a form? I would like it to perform the same action as tab (and move between the input boxes on my form) seeing as that is the sort of thing my users are used to..

2. Is there any easy way to format the content of a text box to only accept numbers and slashes (for date entry) (i.e. 19/03/78)..

3. How do you get a pop up window to be centred on the screen?.

All of these bits and pieces are things I have done before but forgotten. Please help me before I decide to go and boil my head!.

Oh yes, all done in ASP / Javascript if poss - I don't know PHP / Perl etc...

Comments (4)

Hmm... I need to find out myself. I don't know what is the answer. I'll do some poking around and get back to you if I find an anything. You should email the people at iPage as they probably can answer it..

Comment #1

Here is a script to validate a date in the form yyyy-mm-dd. (it will also take yyyy-m-d, yyyy.mm.d, yyyy/m/dd etc.).

Function validDate(inStr) {.

Var date_re = /^\s*(\d{4})[/\.\-\s](\d{1,2})[/\.\-\s](\d{1,2})$/.

Var matchArray = date_re.exec(inStr);.

If (!matchArray) return false;.

Var year = parseInt(matchArray[1],10);.

Var month = parseInt(matchArray[2],10) - 1; //*******s.

Var day = parseInt(matchArray[3],10);.

If (year < 1900 || year > 2100) return false;.

Var realDate = new Date(year, month, day);.

If (year != realDate.getYear() ||.

Month != realDate.getMonth() ||.

Day != realDate.getDate()).

Return false;.

Return realDate;.

}.

It returns either boolean false (if not a valid date), or a Date object representing the date. It works by utilizing the fact that JavaScript will convert rubbish dates for you. For instance whereas new Date(2001, 1, 20) makes a Date of February 20th 2001 [remembering that the stupid *******s who designed the months in Java Dates had them go from 0..11 and not 1..12], new Date(2001, 1, 38) makes a Date of March 10th 2001. By the way, (new Date(2001, 2, 0)).getDate() is a good way of finding out how many days are in February 2001, but I digress..

If you want to compare two Date objects, use the getTime() method. ie. if (date1.getTime() > date2.getTime()).

To test for alpha-digit-alpha, use:.

Var someString = "f8Y".

Var re_ada = /[a-z]\d[a-z]/i.

Var result = re_ada.test(someString);..

Comment #2

Thanks for the expressions Jon!.

Unfortunately the code doesn't like any year before 2000. The code you provided returns boolean false after....

If (year != realDate.getYear() ||.

Month != realDate.getMonth() ||.

Day != realDate.getDate()).

Return false;.

(it fails on the year comparison).

Ideas?!?!.

Thanks,.

Ian...

Comment #3

Sorry about that..

For years between 1900 and 1999, getYear() returns the (year - 1900) so for 1997 it returns 97. So all you need to do is:.

Var theYear = realDate.getYear();.

If (theYear < 100) theYear += 1900;.

There is a new method in IE called getFullYear() which returns the proper year (1987, 2003 etc.).

I'm not sure if Netscape has it...

Comment #4

FetFullYear is able to run on any browser with Javascript 1.1..

Comment #5


This question was taken from a support group/message board and re-posted here so others can learn from it.