.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Onchange event for datetime field in javascript is not working?

Posted By:      Posted Date: September 30, 2010    Points: 0   Category :SharePoint

I want to compare start date and end date when start date is changed. If start date is big, on change event i need to make the end date the same as start date.

So I wrote On change event for start date. But it doesnot work  

getField('input','Start Time').onchange = function() {showEndDate()};


function showEndDate()



var date1 = getField('input','Start Time');

var date2 = getField('input','End Time');


but its not firing at all. So you guys have any idea or any other way to do for datetime on change event?

View Complete Post

More Related Resource Links

Set the DateTime field using javascript

Hi everyone, I need Help in implementing a solution. I have 2 fields: Resolution Date (DateTime) and Severity (Dropdown) and I need depending on the choise in dropdown (0-3) set different dates into the DateTime field. The difficult part is that I can't realize how is to SET the date there %) Here is my code: var ExpDateResolved = $("input[title=Expected Resolution Date]").first(); $("select[title=Severity]").first().change(function(){ ExpDateResolved.val(''); var chbReqSevDom = $(this).get(0); if (chbReqSevDom.selectedIndex == 0)  //first value in dropdown selected { var currentDate = new Date(); DateResolved.val(zeroPad(currentDate.getDate(),2) + '.' + zeroPad((currentDate.getMonth()+1),2) + '.' + currentDate.getFullYear()); } } P.S. I've tried to set a date into a Text field and it works.

getting time and date from datetime field in javascript


Hello guys, I need to get hours from the difference between two datetime fields. I wrote the javascript which will get the date from datetime field.

But its not getting the correct time that entered on date time field. Its defaultly getting the current time on my system.

So do you guys have any idea. How to get time from date time fields. and how calculate hours between two datetime fields using javascript.

hide datetime field from NewForm of a list using javascript


I want to hide Datetime control (entire row) from Newform.aspx of a list using javascript. i am using the following code but its not working for Date time field  else its working fine for TextField.

var DateOfwin=document.getElementById(getTagFromIdentifier('input','DateTimeFieldDate','Date of Win').id);

(above code only hide the calander field i want to hide the entire row)


how to impose javascript event processing?


If I have some form control like textbox and I want the event handler to be located in the html instead of at the server side, how to do that? Of course I can copy paste javascript code in the aspx file. But is it possible to do that using some object oriented approach (ie programmatically in the code behind)?


Dropdown Event (Template Field)



I have grid view control that includes a dropdown control in a template field.

I wish to execute some code when the value is changed in the dropdown list.  Can't figure out how to capture this event though?

Any suggestions?

Closing Javascript Modal dialog window after server side event processing


Hello Friends..

Please tell me how to close Javascript ModelDoalog Window.. after Server Side event Processing .

Basically i want close window in  finally Block After sucessfulll Updation.

AMit..... InnocentInnocentInnocentInnocentInnocentInnocentInnocent

Mission Impossible? Use Javascript to Disable a Multi-Line Rich Text Field


Hey Community,

Here's a tough one that I have struggled with and so far have not been able to find an answer for - how do you use Javascript to disable a multi-line rich text field.  I have customized a SP Edit form by adding a CEWP.  In the CEWP I have added the Javascript below (only a partial code sample provided) to disable several fields in the form.  The code works fine for single line text fields but it does not work for multi-line rich text fields.  Any suggestions?

<script language="javascript">
//This runs the function when the form first loads

//This locks the fields the users should not modify
function lockFields()
  var theInputTFTitle = getTagFromIdentifierAndTitle("Input","TextField","Title");
  theInputTFTitle.readOnly = true;
  theInputTFTitle.style.color = 'gray';
  //alert(" Value: " + theInputTFTitle.value);//for testing

   var theInputDDLReplyStatus = getTagFromIdentifierAndTitle("select","DropDownChoice","Reply Status");
  theInputDDLReplyStatus.disabled = true;
  //alert(" Value: " + theInputDDLReplyStatus.value);//for testing

  var theInpu

How to write an event to manage permissions on a document while uploading, depending on custom field



I am trying to find a solution to manage permissions on a document, while uploading it into a document library. This event has to be fired if a custom field is populated (it's a check box field).

How to write an event for this, i tried writing ItemAdded event, but this is getting fired as soon as a document is uploaded, before coming to the page, where we populate all the fields and hit check in.

can i capture Check-in event.

Please advise.


javascript function not working with datalist


I have a datalist and there is a check box within this datalist in a .ascx page.  But I have to have an image out side the datalist.  So here is the code and its not owrking.  When I click on the image, I dont see any alert box. 


<script Language="JavaScript" type="text/javascript">


function validate_checkbox()



// set var checkboxSelect to zero

var checkboxSelect = 0;

var sProducts = "";


var multiCheck = window.document.forms["frmCompare"].CompareCheck.length;


if (multiCheck != null)


    // Loop from zero to the one minus the number of checkbox button selections

    for (counter = 0; counter < window.document.forms["frmCompare"].CompareCheck.length; counter++)


        if (window.document.forms["frmCompare"].CompareCheck[counter].checked)


            var seperator = (checkboxSelect > 0)?",":"";

            sProducts += sep

Creating a custom drop down field type with SelectedIndexChanged Event

Hi All, I am trying to create a custom drop down field type and I was able to acheive that using the MS link http://msdn.microsoft.com/en-us/library/bb861799.aspx. As per the link, once the custom field is created we can override the "Validate" method to write the Validation logic and that works fine for me too. However I am facing a challenge even before going to Validate . Let me explain my actual requirements here. I need to build a custom drop down field and expose the field to the user in "Edit Properties " Page of a document library. Along with this field, I will be having some OOB site columns in the Edit Properties Page (Ex: Title, Subject etc)  . When user selects a value in the drop down, I need to hide/show few OOB site columns based on certain criteria.  I am facing a challenge of how to capture the "SelectedIndexChanged " event for the Custom drop down field in Sharepoint (Can we wire the SelectedIndexChanged event to a custom dropdown field type) ? Is this acheivable in SP 2010 Custom field type ? If so, how can I do it ? Can any of you kindly help me here?   Regards, Yesh

Keypress Event for Input not working

HelloI use code below code to call function "search" but it only works when users click on button. Keypress event for input does not working.Culd any one plesae tell me why? <input type="text" name="q" id="q" onkeypress="if(event.keyCode==13) FillForm();" autocomplete="off" /> <input type="button" value="Go" onclick="FillForm()" />

javascript not working in iframe on remote site

<html> <body style="background-color: White;"> <form name="ctl01" method="post" action="adv_links_addbycustomer.aspx" id="ctl01"> <div> <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/</div> <div> <input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/dfdafa" /> </div> <div style="background-color:White;"> <span id="lblMsg" class="ErrorText" style="font-weight:bold;"></span> <center> <span id="Label1" style="font-size:X-Small;font-weight:bold;">Valid Urls</span> <select name="DropDownList1" id="DropDownList1" style="background-color:#EFEFEF;border-color:#898989;border-width:1px;border-style:Solid;font-size:8pt;padding:0px;"> <option value="0"> - Select - </option> <option value="http://www.fha-home-loans.us/index.htm">http://www.fha-home-loans.us/index.htm</option> <option value="http://www.fha-home-loans.us/jumbomortgage/apply.htm">http://www.fha-home-loans.us/jumbomortgage/apply.htm</op

Coding is not working for Making Password Field Encrypted in sql and using sessions .basically its a

Dim cn As SqlConnection         Dim cmd As SqlCommand         Dim dr As SqlDataReader         cn = New SqlConnection         cn.ConnectionString = ConfigurationManager.ConnectionStrings("fees_systemConnectionString").ToString         cn.Open()         cmd.Connection = cn         cmd.CommandType = CommandType.Text         Dim Hashpass As String = FormsAuthentication.HashPasswordForStoringInConfigFile(password.Text, "sha1")         cmd.CommandText = "Select * from login where username='" & Me.txtUsername.Text & "' and password = '" & Hashpass & "'"         Dim re As SqlDataReader = cmd.ExecuteReader()         If re.HasRows Then             While re.Read()                 Session("email_id") = re("username").ToString()                 Session("MemberType") = re("type").ToString()                 Session("ISLOGIN&

Team Discussion Modified by field not working

Hello, I have a team discussion board set up which uses a threaded format. However, my issue is with the Modified by field. I believed this would show me the last user that had replied to a discussion but the field continues to display my user name since I was the creator of the discussions in the first place. Am I using the wrong field? Something tells me that the columns I have to choose from are all in regards to to discussions and not to the message replies themselves. In the end, I'm looking for something very similar to your forums here. Discussions should be displayed with title, created by, timestamp, last user who replied and timestamp.Beth Singley PBM Graphics

Trap Selected Index change event of listbox using Javascript.

Hi All, This is reagarding listbox selection. I have a list box with multi select option. I want to trap the selected index change event of Listbox through javascript. Item of list box can be selected using Click of mouse and also the keyboard up down key with shift. I tried onclick event to bind the javascript function. It works fine if I select by mouse, but it doesen't work for up/down key of keyboard. Thanks, Naveen

CompareTo not working for DateTime

Hi,I have a bit of an odd problem. I have a grid that i must load some data to and sort it by date. I implemented CompareTo but it doesn't seem to work at all.The objects in the grid seem to be put there at random. I tried to implement compareto in 3 ways. None of them worked. I do  the sorting before i bind to the grid.The code for the compareto method is this:public int CompareTo(Issue to) { if (this.LastStatusDate.Year > to.LastStatusDate.Year) return 1; else return 0; if ((this.LastStatusDate.Year == to.LastStatusDate.Year) && (this.LastStatusDate.Month > to.LastStatusDate.Month)) return 1; else return 0; if ((this.LastStatusDate.Year == to.LastStatusDate.Year) && (this.LastStatusDate.Month == to.LastStatusDate.Month) && (this.LastStatusDate.Day > to.LastStatusDate.Day)) return 1; else return 0; if ((this.LastStatusDate.Year == to.LastStatusDate.Year) && (this.LastStatusDate.Month == to.LastStatusDate.Month) && (this.LastStatusDate.Day == to.LastStatusDate.Day) && (this.LastStatusDate.Hour > to.LastStatusDate.Hour)) return 1; else return 0; }The other 2 versions i tried were:public int CompareTo(Issue to) {

Comparing Datetime field in DB?

I need to check the datetime field in my DB to see if the time that's current set is 12hr's past? What's the command to use?  Can I just DATEDIFF? 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend