Please provide me support and alternative solution to the following mention problem. I would be grateful to you.
I have two text boxes on the page named PSDate(means start date) and PFDate(means final date).
While saving the form i have to check final date should be greater than the start date.
I'm not able to get the value entered by the user in the text boxes.
function checkdate1() { <% Date d1 = DateFormat.parse(%> document.CreateProject.PSDate.value <%); Date d2 = DateFormat.parse(%> document.CreateProject.PFDate.value <%); int check = D1.compareTo(D2); if(check==0) { System.out.println("You can't enter the same date"); } else if (check>0) { System.out.println("You can't enter the previous date"); } %>
When you have written the above code (in the begining/middle/last)in the JSP file. And when you are calling this function.(on button click etc). Kindly give more details for your problem.
*********************************** Tip: Modesty is all virtue. ***********************************
I can't quite tell from the code, but it looks like you're mixing JSP code (which runs on the server, long before the page gets to the browser) with JavaScript code (which runs in the browser). JSP code doesn't have access to form fields, nor can JavaScript code call Java functions. This article should make things clearer. [ May 22, 2007: Message edited by: Ulf Dittmer ]
As far as I understand is you are trying to generate Date d1 = DateFormat.parse(%> document.CreateProject.PSDate.value <%); to something as Date d1 = DateFormat.parse("10/12/2007");
This wouldn't work. This code wouldn't compile.
Keep in mind that whatever you write in the JSP is converted to java code. Now this happens only once. Now when you are calling function checkdate1() it's not that it will call the java method and generate the output.
You would have to put in a function in javascript for what you want in java or you could use AJAX for the same. I would suggest using a javascript function if it's just date parsing.