473,385 Members | 1,645 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

javascript in asp.net

hi if u please help me in javascript

i have to write a javascrit in asp.net to validate tow date textbox(txt_fromdate,txt_todate and from date have to be less then to date else i have to show a alert "u have to enter from date less than to date "


when i click btn_find


10x for helping me
Sep 20 '07 #1
4 990
ammoos
100 100+
Please check the following code

private void Page_Load(object sender, System.EventArgs e)
{
btn_find.Attributes.Add("OnClick","checkDate()");
}
// html page
<HTML>
<HEAD>
------
-------------------------
-------------------------
<script type="text/javascript">
function checkDate()
{
var dateFrom = new Date(document.getElementById('txt_fromdate').value );
var dateTo = new Date(document.getElementById('txt_todate').value);
if(dateFrom > dateTo)
alert(‘u have to enter from date less than to date’);
}
</script>
</HEAD>
Sep 20 '07 #2
Adding event handlers via Attributes isn't absolutely necessary with a Button; it would be with a checkbox or a radio button, which don't have an onclick in ASP.NET, so you'd receive an annoying warning. With a button, you just need to write
Expand|Select|Wrap|Line Numbers
  1. onclick="checkDate();"
in the asp tag, and that's it.
Sep 20 '07 #3
it work fine


10x for helping me
Sep 20 '07 #4
Frinavale
9,735 Expert Mod 8TB
I'm glad you got it working.
For more information and examples on how to use JavaScript in .NET, you should check out the .NET Article on How to check if a textbox contains a number.

Cheers!

-Frinny
Sep 20 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.