Forums

This topic is locked

date format function

Posted 20 Mar 2008 08:46:36
1
has voted
20 Mar 2008 08:46:36 fabiola jod posted:
any smart person out there please help me.
I'm using dreamweaver mx with asp pages.I want to populate current data in a text field.This is the code i'm using.
<td align="right">Date:</td>
<td><input type="Date" name="txtDate" value="<%=Date() %>" readonly="true"></td>
the problem is my date comes in the m/d/yyyy format.i want it to come in mm/dd/yyyy format .i don't know what to do i tried everything.please help

Replies

Replied 20 Mar 2008 13:16:58
20 Mar 2008 13:16:58 Georgi Kralev replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
any smart person out there please help me.
I'm using dreamweaver mx with asp pages.I want to populate current data in a text field.This is the code i'm using.
&lt;td align="right"&gt;Date:&lt;/td&gt;
&lt;td&gt;&lt;input type="Date" name="txtDate" value="&lt;%=Date() %&gt;" readonly="true"&gt;&lt;/td&gt;
the problem is my date comes in the m/d/yyyy format.i want it to come in mm/dd/yyyy format .i don't know what to do i tried everything.please help
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Hi fabiola,

Search the Internet. There are number of solutions for this issue.

You can check the one that I have found through the following link:
www.eggheadcafe.com/PrintSearchContent.asp?LINKID=127

If it suit your need you can use it.

Regards,




Georgi Kralev

Homepage: gdkralev.googlepages.com
Replied 24 Mar 2008 18:55:21
24 Mar 2008 18:55:21 fabiola jod replied:
thanks for the reply it worked i could change the date format.I want to ask another question.I'm trying to do validation on my asp pages.I want to validate so that the text field should not be empty and it should only take numbers.I'm using the function below.


function validateMyForm(I)
{


if(I.txtNewROP.value ==""{
alert('Cannot leave the New Max field blank!');
return false;

}
if(!IsNumeric(I.txtNewROP.value)){
alert('Please enter number in new rop field')
return false;
}

return true;

}

the problem is my function works well with the validation of the empty string but it does not validate if the user entered a number or character. it only validates the first part and leaves the validation of the numbers blank.i don't know why it's not working for the second validation.help please
Replied 24 Mar 2008 18:57:00
24 Mar 2008 18:57:00 fabiola jod replied:
thanks for the reply it worked i could change the date format.I want to ask another question.I'm trying to do validation on my asp pages.I want to validate so that the text field should not be empty and it should only take numbers.I'm using the function below.


function validateMyForm(I)
{


if(I.txtNewROP.value ==""{
alert('Cannot leave the New Max field blank!');
return false;

}
if(!IsNumeric(I.txtNewROP.value)){
alert('Please enter number in new rop field')
return false;
}

return true;

}

the problem is my function works well with the validation of the empty string but it does not validate if the user entered a number or character. it only validates the first part and leaves the validation of the numbers blank.i don't know why it's not working for the second validation.help please
Replied 25 Mar 2008 01:16:11
25 Mar 2008 01:16:11 Georgi Kralev replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
thanks for the reply it worked i could change the date format.I want to ask another question.I'm trying to do validation on my asp pages.I want to validate so that the text field should not be empty and it should only take numbers.I'm using the function below.


function validateMyForm(I)
{


if(I.txtNewROP.value ==""{
alert('Cannot leave the New Max field blank!');
return false;

}
if(!IsNumeric(I.txtNewROP.value)){
alert('Please enter number in new rop field')
return false;
}

return true;

}

the problem is my function works well with the validation of the empty string but it does not validate if the user entered a number or character. it only validates the first part and leaves the validation of the numbers blank.i don't know why it's not working for the second validation.help please

<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Hi fabiola,

It looks like there is a problem with your JavaScript.
Check your browser for JavaScript errors.

For example you have missing <b>;</b> character at the following line:
<i>alert('Please enter number in new rop field')</i>

Also make sure the <b>IsNumeric</b> JavaScript function is defined.

If it is not you can try the following implementation of IsNumeric function:
function IsNumeric(strString)
// check for valid numeric strings
{
var strValidChars = "0123456789.-";
var strChar;
var blnResult = true;

if (strString.length == 0) return false;

// test strString consists of valid characters listed above
for (i = 0; i &lt; strString.length && blnResult == true; i++)
{
strChar = strString.charAt(i);
if (strValidChars.indexOf(strChar) == -1)
{
blnResult = false;
}
}
return blnResult;
}


For more information you can check the following link:
www.pbdr.com/vbtips/asp/JavaNumberValid.htm

I hope this helps you.

Ragards,


Georgi Kralev

Homepage: gdkralev.googlepages.com
Replied 25 Mar 2008 08:53:25
25 Mar 2008 08:53:25 fabiola jod replied:
thank you very much for your quick reply. it was a very simple error i left out a semi colon at the end of one of my codes.now my fields are being validated.I don't know if i'm asking for a lot but i want to use calendar control on one of the pages but have no idea where to start i don't even have a calendar for starters.but i know my asp page name is MRPSummary.asp and the text field where i want my date to be inserted is this.
&lt;td width="10%"&gt;&lt;input name="txtsearch" type="text" &gt;
my search function is fine it retrieves the record i just don't want the user to enter the date manually.the date format is in m/dd/yyyy.
Replied 25 Mar 2008 11:41:52
25 Mar 2008 11:41:52 fabiola jod replied:
okey i have manage to find something on the internet.im using this code
&lt;td width="10%"&gt;&lt;input name="txtsearch" type="text" &gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="javascript: void(0);" onmouseover="if (timeoutId) clearTimeout(timeoutId);window.status='Show Calendar';return true;" onmouseout="if (timeoutDelay) calendarTimeout();window.status='';" onclick="g_Calendar.show(event,'frm.ex1',true, 'mm/dd/yyyy', new Date(2003,2,15),new Date(2003,3,25)); return false;"&gt;&lt;img src="images/calendar.gif" name="imgCalendar" width="34" height="21" border="0" alt=""&gt;&lt;/a&gt;&lt;/td&gt;
I don't know but if i click on the calendar on my page it does not popup.I'm trying to create a a calendar control on my asp pages with javascript.If you have any other suggestion besides this method i won't mind trying it out.I just don't know what to do.
Replied 27 Mar 2008 00:15:05
27 Mar 2008 00:15:05 Georgi Kralev replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
okey i have manage to find something on the internet.im using this code
&lt;td width="10%"&gt;&lt;input name="txtsearch" type="text" &gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="javascript: void(0);" onmouseover="if (timeoutId) clearTimeout(timeoutId);window.status='Show Calendar';return true;" onmouseout="if (timeoutDelay) calendarTimeout();window.status='';" onclick="g_Calendar.show(event,'frm.ex1',true, 'mm/dd/yyyy', new Date(2003,2,15),new Date(2003,3,25)); return false;"&gt;&lt;img src="images/calendar.gif" name="imgCalendar" width="34" height="21" border="0" alt=""&gt;&lt;/a&gt;&lt;/td&gt;
I don't know but if i click on the calendar on my page it does not popup.I'm trying to create a a calendar control on my asp pages with javascript.If you have any other suggestion besides this method i won't mind trying it out.I just don't know what to do.

<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

In Internet you can find many different JavaScript calendars (with good description how to be used).
1. About the one that you are using, check if the following files are uploaded at your server:
calendar.css
simplecalendar.js

2. Also, check in the following lines if the paths to them are correct:
&lt;link rel="STYLESHEET" type="text/css" href="<b>styles/calendar.css</b>"&gt;
&lt;script language="JavaScript" src="<b>javascript/simplecalendar.js</b>" type="text/javascript"&gt;&lt;/script&gt;

3. Also, make sure that your form is called <b>frm</b> and you have input will the name <b>ex1</b>
For example:
&lt;form name="frm" method="post" action=""&gt;
&lt;input type="text" name="ex1"&gt;

Hope this helps.

Georgi Kralev

Homepage: gdkralev.googlepages.com

Reply to this topic