Validate date in coldfusion or javascript???

Hi,
I had a form that contains date field and user enters date as 06/09/2009,but when user enters date in the date field the date field has to be validate to the last day of that month.
For example if i enters 06/09/2009 then it has to validate for the month 06 and no of days in that month.
After validation i have to set that last day of month as the expiration date for the gift card.
Would please help me in this i have no idea in this
Thanks.

Hi,
Use DaysInMonth() function and find the number of days in month.
For finding last date of month use follwing code.
<cfset currentMonthDate = CreateDate(year(Now()),month(dateAdd('m',1,Now())),1)>
<cfset lastDayOfMonth = dateAdd('d',-1,createdNextMonthDate)>
Thanks

Similar Messages

  • Validate Date and block JavaScript page change

    how I can validate date acrobat, can block JavaScript page change, only change with a button? 

    If you use the "util.scand" method date validation is part of the process. It either returns the number of milliseconds from the Epoch date used by JavaScript for the date time object the null value.
    Date Arithmetic has some sample scripts, but you need to keep in mind that Date and Time are not independent and using "new Date()" returns the date and time at the time that line of code is executed and that can cause issues for the computing of dates only.
    Are you sure of day count, most differences include the start and end dates in the number of days for the calculation.
    Custom calculation for today's date field (format is None):
    // get today's date an time
    var oToday = new Date();
    // set to start of day
    oToday.setFullYear(oToday.getFullYear(), oToday.getMonth(), oToday.getDate(), 0, 0, 0, 0)
    // set field value
    event.value = util.printd("d/mm/yyyy", oToday);
    Custom calculation for the difference in days field (format None):
    var cEnteredDate = this.getField("EnteredDate").value;
    var cToday = this.getField("Today").value;
    event.value = "";
    if(cEnteredDate != "" && cToday != "") {
    // process only if date values not empty
    // convert date strings to date time objectat midnight
    var oEnteredDate = util.scand("d/mm/yyyy", cEnteredDate );
    if (oEnteredDate == null) {
    app.alert("Error in processing entered date", 2, 0);
    oEnteredDate.setFullYear(oEnteredDate.getFullYear(), oEnteredDate.getMonth(),oEnteredDate.getDate(), 0, 0, 0, 0) 
    var oToday = util.scand("d/mm/yyyy", cToday);
    if(oToday ==  null) {
    app.alert("Error converting today", 2,0);
    oToday.setFullYear(oToday.getFullYear(), oToday.getMonth(),oToday.getDate(), 0, 0, 0, 0) 
    // convert date objects to days
    var nEnteredDate = Math.floor(oEnteredDate.getTime() / (1000 * 60 * 60 * 24));
    var nToday = Math.floor(oToday.getTime() / (1000 * 60 * 60 * 24));
    // compute & format the difference
    event.value = util.printf("%,0 1.0f", (nToday - nEnteredDate));

  • Validate Data in Web Form

    we want to validate data in web form in planning through Java Script Code ?
    how we can do it and what is the location of that Java Script file ?
    One more thing ... if we make any changes in Java Script code then is it necessary to stop and start planning server or application ?
    Thanks in Advance ..... :-)

    Hi,
    you can resolve this problem, adding a JavaScript code in validateData.js.
    For example you can change and/or insert the code in validateForm function, that save the data only if the function return true.
    There are also another function and the code example in SampleValidateData.js that you can see.
    You find the ValidateData.js in the folder "custom" of your installation.
    For example:
    /default web application directory/deployments/your web server/HyperionPlanning/webapps/HyperionPlanning/custom
    I report an example for control the data before saving it:
    function validateForm(){
    if (equalsIgnoreCase(applicationName,"BDG"))
    if (equalsIgnoreCase(formName,"1.10A ECO"))
    var rowPrecVers = currentDataGrid.endRow;
    var colPrecVers = 2;
    var rowActVers = 3;
    var colActVers = 3;
    var valTotPrecVers = 0;
    var valTotActVers = 0;
    valTotPrecVers = currentDataGrid.fullPrecision[rowPrecVers][colPrecVers];
    for(rowActVers; rowActVers < currentDataGrid.endRow; rowActVers++){
    valTotActVers = valTotActVers + parseFloat(currentDataGrid.fullPrecision[rowActVers][colActVers]);
    if(valTotPrecVers < valTotActVers){
    alert("Ops!!!Don't match" + "\n"
    + "Previous Version: " + valTotPrecVers + "\n"
    + "Actual Version: " + valTotActVers);
    valid = false;
    return valid;
    else{
    return valid;
    Insert and modify this code in validateForm function.
    If in your installation use Tomcat web server, you must save the change on the ValidateData.js file each time. If you use the WebLogic web server tou must restart the service. For other web server I don't know.
    Take it easy and have fun!!!
    Flavio

  • Getting error while tring to Check in any document in Sharepoint 2007. Error - "Unable to validate data. System.Web.Configuration.MachineKey.GetDecodedData(Byte[] buf, Byte[] modifier, Int32 start, Int32 length, Int32& dataLength) ...

    Hi Team,
    I am getting error while tring to Check in any document in Sharepoint 2007. Error - "Unable to validate data. System.Web.Configuration.MachineKey.GetDecodedData(Byte[] buf, Byte[] modifier, Int32 start, Int32 length, Int32& dataLength).
    Anybody please let me know how to resolve the issue. It has affected our 9 site collection with almost 2000+ sites. Please email me your your suggestion or you can share your ideas here also.
    Tried to reset the IIS, checked the Internet connection speed (8MBps). Cleared the cache and all but no luck.
    Thanks,
    Pronob

    Hello,
    I have found this support window for you:
    http://support.microsoft.com/kb/556031
    http://technet.microsoft.com/en-in/library/cc298582%28v=office.12%29.aspx
    This may help you
    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • How to create and use Data Vault with HTML/JavaScript (SAPUI5) for Mobile Apps?

    Hello,
    I am creating a demo Enterprise Mobile App, for cross platform and I want to use the Data Vault.
    I am not able to figure out how to implement the Data Vault with HTML/JavaScript i.e. SAPUI5 for cross platform mobile apps I have a tutorial, but it is for Android based apps. Where as I want it for iOS as well. I guess, in this case, implementing the Data Vault using SAPUI5 over HTML and JavaScript would be  better.
    If anyone has any links or sample code to implement Data vault in HTML/JavaScript (SAPUI5) or specific for iOS apps, it would be great.
    Thank you.

    Hi,
    This is the "SAP Mobile Documents" community, so this seems to be the wrong place for asking your question related to Data Vault / SAPUI5.
    Maybe you should post your question here: http://scn.sap.com/community/developer-center/front-end.
    best regards,
    Ingo

  • Can you please help to understand how the firefox decides on the Expires date for a cached javascript file ( my server did not set any Expire header, but firebox set it down).

    # Question
    Can you please help to understand how the firefox decides on the Expires date for a cached javascript file ( my server did not set any Expire header, but firebox set it down). I tried to understand but different javascript file gets different Expires date value when it is being cached. Please help me as I tried lot and could not get proper answer for this. Thanks in Advance.

    Try posting at the Web Development / Standards Evangelism forum at MozillaZine. The helpers over there are more knowledgeable about web page development issues with Firefox. <br />
    http://forums.mozillazine.org/viewforum.php?f=25 <br />
    You'll need to register and login to be able to post in that forum.

  • How to validate Date

    Hi,
    We have a date field in the form. I am validating date format as YYYY-MM-DD, validation works fine. But If user enters invalid date, how to validate date? For examples:
    2006-02-31 It is an invalid date. How can i validate it.
    If anybody have sample code, it will help me a lot.
    thanks
    Neopal.

    Hi Neopal,
    You can use something like the following to test the date is valid, use the validation event on the <Field> which you want to validate to call a Rule something like this (not complete)..
      <Rule name='isDateValid'>
            <RuleArgument name='date'/>
            <block>
           <script>
              var dateToTest = env.get('date');
              var formatter = new java.text.SimpleDateFormat('YYYY-MM-DD');
              Date validDate = formatter.parse(dateToTest);

  • Function Module to validate date

    Hi,
    Is there a Function module to validate date in transfer rules or update rules. I checked the forum, couldn't find an answer. Any help is appreciated
    Thanks
    Bala

    You should be able to use this FM:
    CALL FUNCTION 'RSAR_DATE_CHECK_PLAUSIBILITY'
      EXPORTING
        i_date                          = yourdate
    EXCEPTIONS
       PLAUSIBILITY_CHECK_FAILED       = 1

  • Validate Date Range in inputDate component

    Hi
    I am using JDev 11.1.1.2.0
    I have an inputDate component which on click i need to give dates from today to future dates not passed dates.
    So i have included 'validate date time range' component in the inputDate component and in the minimum property i have declared 'adf.currentDate' using expression builder and set the maximum as Jan 31,2099.
    But when i execute my application i am able to select passed dates using the inputDate component, please help how can i check the date using a validator in inputDate component.
    Thanks
    Sudeep

    ya i had tried with that property too....
    i have declared minValue as adf.currentDate and on that it changes the value of maxValue to current date in Jan 3,2012
    i have convertDatetime component in my inputDate to display the selected date in certain format.
    It gives error as the format doesnot matches with the convertDatetime and inputDate component.
    How can i use the minValue and maxValue of inputDate component?
    the component:-
    <af:inputDate
    label="Planned Termination Date"
    id="id2"
    value="#{modifyuser.pterminationdate}"
    valueChangeListener="#{modifyuserfields.plannedTermDate}"
    minValue="adf.currentDate" maxValue="2099-12-31">
    <af:convertDateTime pattern="dd-MMM-yyyy"/>
    </af:inputDate>

  • Validate date ?

    Dear All,
    May I enquire how to validate date for:
    textDateofLoss.getText()
    Is it:
    if isDate(textDateofLoss.getText()){
    //True date
    else{
    //False date}
    Please advise.

    Sorry, have to use the following:
    import java.util.*;
    import java.text.*;
    public class validateDate {
    public static void main(String args[]) {
    String dt = "10-10-1990";
    String format = "dd-mm-yyyy";
    // String dt = "1990-10/10" throws a ParseException
    // String dt = "1990-10-35" throws a IllegalArgumentException
    try {
    //DateFormat df =
    //DateFormat.getDateInstance(DateFormat.SHORT);
    SimpleDateFormat df = new SimpleDateFormat(format);
    df.setLenient(false); // this is important!
    Date dt2 = df.parse(dt);
    System.out.println("Date is ok = " + dt2);
    catch (ParseException e) {
    System.out.println(e.getMessage());
    catch (IllegalArgumentException e) {
    System.out.println("Invalid date");
    }

  • Validate date using RE

    Hey guys,
    Need to validate date using RE in format MM/DD/YYYY and optional HH:MM:SS
    I already have simple solution, but would like to add checks for leap year and dates like 02/30/2006 or 04/31/2006
    So far I have this:
    private static final String datePattern =
         "^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\\d\\d" +
         "(\\s(([0-1]?[0-9]|2[0-3]):([0-5]?[0-9]):([0-5]?[0-9]))){0,1}$";

    A much better way is to specify the format of the data and parse it using the SimpleDateFormat class method parse.

  • Validate date of Birth

    How I can validate date of birth?
    Month-Date-Year
    Example: 11-21-1960
    Thanks

    You could use a regular expression:
    E.g.
    var dateRegExp = "^(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])-(19|20)\d\d$"; // mm-dd-yyyy
    if (oField.rawValue.search(dateRegExp) === -1) {
         // error!
    Or you could use a date object as suggested in the previous post, but also stop the user from typing in a date so they will be forced to use the date selection box. This would ensure that the date is always in the correct format. To stop the user from typing in data, put the following code in the change event for the field:
    if (xfa.event.change.length == 1) {
    xfa.event.change = "";

  • [BPC 7.5] or [BPC 10] Validate data from different periods

    Hi,
    is it possible to use the standard validation business rule to validate data in different periods? I need a rule that validates the total in my flow dimension from last year end to the value in the opening flow in the current period. Is that possible?
    Thanks,
    Arnold

    Hi Arnold,
    I do not think this is possible. You can only compare accounts and flows in the detailed rules. In the Header rules you can specify specific dimensions and time periods.
    You can maybe use script logic to write data to the current month into a validation test account from the last year into the current period and then run the validation rules.
    Thanks,
    John

  • I used firefox 3.6.14 on windows 7 x64 (firxfox x32). I found a problem when I develop my website and alert data or value via javascript , firefox hang (not response) every time. What's happend? How to solve is problem?

    I used firefox 3.6.14 on windows 7 x64 (firxfox x32). I found a problem when I develop my website and alert data or value via javascript , firefox hang (not response) every time. What's happend? How to solve is problem?
    Thank you for help
    Lohkaeo

    Oops - for some reason, this problem now seems to have gone away. May have had something to do with Flash. I'll keep my fingers crossed.

  • RegEx to validate date between 1900 & today

    Hi,
    I have a RegEx which validates the date of birth
    (0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)dd
    But I want it to validate date of birth until today only from 1900
    How can I do that using regular expression?
    a®s
    Edited by: a®s on Jul 2, 2008 3:00 PM

    Thanks for your reply Jan.
    Jan Stallkamp wrote:
    > In general regex tend to be easy to write but hard to read. So from a maintance perspective they might not be the best choice. >
    I accept the fact that you mentioned above.
    I am planning different RegEx for different date formats.
    This application need to be called from a PHP page. so don't find any other way to tackle this issue.
    Any other info?

Maybe you are looking for

  • Iweb/itunes problem - host parameter is null

    i use iweb to publish and host our website. everything works fine, except... i have never been able to successfully publish a podcast to itunes through iweb. the error message in itunes is that the host parameter is null. i'm really scratching my hea

  • How to find out the Tcodes for the exits

    Hi All, how to find out the Tcodes for the exits. i have a list of exits (customer, user, badi ). i need to find out what are the Tcode affected by this exits. Customer Exits: EXIT_RFEBBU10_001                           EXIT_RFEKA400_001             

  • Profit center substitution with internal order when generating GL doc from

    Profit center substitution with internal order when generating GL doc from MM Dear expert, Please advise how to substitute successfully the profit center by which user-exit via FI substitution function. Substitutions have been set for profit centers

  • Get hurt by using the new macbook

    does anyone agree that the edge of the macbook is quite sharp???? every time i use the keyboard and do my typing, my wrists are very easy to get hurt by the sharp edge of the macbook, even though that hurt is not that serious, just feeling a bit pain

  • Import objects between different SCV

    Hi, How can Import objects between different Software Component Versions Thanks