Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old August 24th, 2005, 07:34 AM
Authorized User
 
Join Date: Aug 2005
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help Needed

I want date valadations in YYMM format and the user this value in textbox

thanks in advance.

  #2 (permalink)  
Old August 24th, 2005, 09:31 AM
Friend of Wrox
 
Join Date: Oct 2004
Location: delhi, delhi, India.
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hii Raj!!

Hope this will help you
<script>
function getVal(obj)
{
strval=obj.value
regexp=/^(\d){4}$/;
if(regexp.test(strval))
{
 years=strval.substring(0,2)
 months=strval.substring(2,4)

  if(years=="00"||months=="00")
    {alert("eerorr in month years can't be 0")
     return false;
     }


  if(parseInt(months)>12)

  {alert("month can't be greater than 12")
       return false;
       }


 return true;
}
else
{
alert("errr YYMM format")
}

}
function getDateFormat(obj1)
{
if(!getVal(obj1))
 {
 document.myform.dt.select();
 document.myform.dt.focus();
 }
else
{
 alert("success")
 }
}
</script>
<form name=myform>

<input type=text name=dt onblur="getDateFormat(this)">
</form>

Cheers :)

vinod
  #3 (permalink)  
Old August 25th, 2005, 04:54 AM
Authorized User
 
Join Date: Aug 2005
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi ,

Thanks a lot for your information and i also need extra valadation
This is the Requirement.
Date entered should not be greater than (current date + 1 month). Suppose if the user is entering fiscal date on ’0507’, the fiscal date should not be greater than ‘0508’.

Thanks in advance,

Special thanks to vinod..

  #4 (permalink)  
Old August 25th, 2005, 05:52 AM
Friend of Wrox
 
Join Date: Oct 2004
Location: delhi, delhi, India.
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

HI Raj !!

If this is the case then you need to store current month/year in hidden variables.
and compare that values in ur function.Why i m giving the idea to store it in hidden text fields is that ,if you rely on client side javascript date ,then the user can change the date setting of his own PC.
So ,now you have hidden cmonth and cyear ,now compare these two with the values entered by the client.
Hope this will help you



Cheers :)

vinod


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help needed ramabharti Javascript How-To 1 December 7th, 2006 06:42 AM
Help needed rrvinod ADO.NET 0 October 5th, 2006 09:44 AM
help needed! paquito Beginning PHP 2 November 16th, 2005 11:51 AM
A Little help needed matthew01 ASP.NET 1.0 and 1.1 Basics 3 November 9th, 2005 11:29 AM
help needed kfarooq Java Databases 1 June 27th, 2003 05:20 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.