Comapre two fileds using javascript

Hi,

I have to textbox fields one is for email and second one is for confirmation email, using Javascript I want to check whether the value in both textboxes are equal or not
I write the function like thie below
<script language="javascript">
<!--
function checkEmail() {
if (document.TheForm.Email.Value != document.TheForm.EmailVerify.Value) {
return false;
}
}
//-->
</script>
 
Now I want to do the above validation in the emailverify textbox is loosing the focus and display the message after that textbox if they didn't match. Don't want the alert. Where to call the method.
Thanks
0
kalkumar
10/4/2007 3:20:46 PM
asp.net.client-side 24353 articles. 1 followers. Follow

2 Replies
500 Views

Similar Articles

[PageSpeed] 14

You'll want to use the onblur event of the textbox. Basically when someone leaves the textbox, the onBlur will be raised.

inside that onblur you will do your javascript.

function checkEmail()
{
    var email = document.getElementByID("Email").value;
    var emailVerify = document.getElementById("EmailVerify").value;
 

   if( email != emailVerify )
{
    alert("Email address:" + email + "  does not match email: "  + emailVerify);
}
else
{
//something about ninjas taking over the world and the validation was successful.
}

}

 --

 You can also use the ASP.NET <asp:CompareValidator /> control.
 

<asp:CompareValidator
id="ProgrammaticID"
ControlToValidate="Programmatic ID of Server Control to Validate"
ValueToCompare="value"
ControlToCompare="value"
Type="DataType"
Operator="Operator Value"
ErrorMessage="Message to display in ValidationSummary control"
Text="Message to display in control"
ForeColor="value"
BackColor="value"
runat="server" >
</asp:CompareValidator>

The Killer Ninja Coding Monkeys thank those that mark helpful posts as answers.

My Site | My Examples | My Blog


0
RTernier
10/4/2007 4:19:21 PM

Like this in Page_Load...

    TextBox1.Attributes.Add("onblur", "checkEmail();")
 
Hope this helps!  Please mark the helpful post(s) as Answer.
Josh Stodola ← Come check out my blog!
0
JoshStodola
10/4/2007 5:05:02 PM
Reply:

Similar Artilces:

How to write data to a file in client side using javascript or someother client side scripting language.
Hi, I would like to know how to write a data to a client side file using javascript or someother client side scripting language. The file type expected is ini file. txt file would also be appreciable. Thanks in advance.   If the site is a trusted and you are running IE then you could try http://www.w3schools.com/asp/asp_ref_filesystem.asp The Old Sewing FactoryThat twitter nonsense. You can write to the server, but not to the client's machine.  Being able to do so would be a huge security breach.When you ask a question, remember to click "mark as answered"...

How to use client-side script(javascript) in DNA using .Net Remoting
Hi all,     It was known that SAO and Singleton object about .Net Remoting. When I Create an object in server side and hosting in IIS's virtual directory,I want to use javascript asynchronous invoking the remote object by HTTP channel, 80 port and SOAP formatter just like XMLHTTP invoking web service. My code as following, <script> objXmlDoc = new ActiveXObject("Msxml2.DOMDocument"); objHttp = new ActiveXObject("Msxml2.XMLHTTP"); strEnvelope = ?? objHttp.onreadystatechange = function() { ...... }   szUrl = "http://ServerNa...

How to use client-side script(javascript) in .Net Remoting
Hi all,     It was known that SAO and Singleton object about .Net Remoting. When I Create an object in server side and hosting in IIS's virtual directory,I want to use javascript asynchronous invoking the remote object by HTTP channel, 80 port and SOAP formatter just like XMLHTTP invoking web service. My code as following, <script>  objXmlDoc = new ActiveXObject("Msxml2.DOMDocument"); objHttp = new ActiveXObject("Msxml2.XMLHTTP"); strEnvelope = ?? objHttp.onreadystatechange = function() { ......  }    szUrl = &...

In datawindow.net,access the database from client side event using javascript
In powerbuilder,for example,a datawindow has two columns:itemno,description. input an itemno,validate it.if not found from the database,return 1 to trigger itemerror event; if found,get the description of the item from the database,and fill it into the column "description". The question is how to fulfill the function in web datawindow,through web service? if so,I need an example to realize it. You will need to use AJAX or make a round trip on item change event. -- Dean Jones CEO PowerObjects http://www.powerobjects.com (612) 339-3355 Ext. 112 TeamSybase * *...

Access web form content from client side HTML file using javascript
I have two browser windows open, one an html file residing on the client and one an aspx page served up by the web server. Neither window is related to the other; neither one opened the other. Is it possible for javascript on the html file which resides on the user's local computer to "read" any of the information from the other open window? Ideally, I'd like to read a hidden input field from the web page. The solution only has to work in IE 6 and 7. Thanks in advance. Man, this sounds more like a virus, like spyware... Why do you need to do such thing? What I want is to open ne...

without server side scripting, can we upload a file using client side scripting if destination folder and config file settings are known? is it possible?
without server side scripting, can we upload a file using client side scripting if destination folder and config file settings are known? is it possible? avdp211:without server side scripting, can we upload a file using client side scripting if destination folder and config file settings are known? is it possible? I don't think it is possible.You use the the HTML input file control and when you post the request, on the web server you need to read the data and save it to a file, so there has to be some interaction with the server to handle the post request.  Not possible vi...

How to call web method directly form client side javascript without using hta file
Hello nice guys, I am a newbie in this forum. I need to be able to call a web service from client side javascript code without using webservices.hta file so it may work on Netscape browsers as well as IE browsers. I don't mind having to form soap request and then post it all in javascript. An example will be very helpful. Do you have any resource I may look up to, like any published article on the net, for code examples or a work around. Thanks Dean51 Hi, I wrote a library to use AJAX to consume Web Services. You can find the article, the source code (less than 8 KB) and some...

When to use client side varidation and server side varidation in .net?
In .net or classic web application we can varidate user data either on client isde or server side. How to select which side varidate to be used? Thanks! Generally, I use both client and server validation. I make sure the input is in the correct format and reasonably valid on the client, then I verify the data on the server. The extent of validation also depends on the type of data that I need to validate.Here are a few references:Validating ASP.NET Server ControlsIntroduction to Validating User Input in Web FormsClient-Side Validation for ASP.NET Server ControlsSecurity Checklist...

how do i get selectedValue of drop down list server side if i am populating it using client side javascript?
 Hi All.I am populating a drop down list client side using: The drop down list is populated based on a selection of another drop down list. ddlList.options[i] = new Option(1,2); as an exampleThe populating is done as i need it to. However, a button click event i am trying to get the selectedValue of the ddlList. However, it doesn't give me it. It only gives me the selectedValue of the drop down list on first rendering. Any ideas on how i can get it?   Could You paste some code? That would be helpful. Thanks S@ss (Shashi Shekhar Singh)My BlogPlease mark a post as ANSWER ...

Javascript: Grab Full Path from Input Type File and Pass to Server for Processing (using Client Callbacks and WebClient.UploadFile to Process File Path)
Hi all, I was wondering if someone can help me out with this. Basically I have a input type file control on the page and when the user browses and selects a file, I use javascript to grab the value and send to server. Since installing IE 8, the input type file no longer retains the complete path (which I need) because I am basically using webclient.uploadfile on server to upload the file. So, I need the complete path for webclient.uploadfile so that the page can post to the second page and then complete file upload. Now IE 8 has stopped retaining the path due to security restrictions. How ...

.Net varible into client side JavaScript
I'm need to get a variable from my web app and place its value in a JavaScript. I tried doing this with a Label but I get the HTML included. I don't think I can use the <%# %> from classic ASP? Anyone have any ideas on how they would approach this problem? tbone_stl wrote:Anyone have any ideas on how they would approach this problem? Hi, and welcome to the ASP.NET forums. It's possible to pass a variable to a javascript function. I created a small coding snippet: <%@ Page Language="C#" %>   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http...

How -to use Client-Side Javascript example?
Can someone please point me to a good example of how to do this? Sorry, but I'm a PowerBuilder developer and still don't understand this. How can you code a javascript file to get data from the webform, use that data, and set a result back to the webform? A small example of coding the itemchanged event would be great. In my app, the user's want to be able to enter data in a field and have that trigger calculations that would populate other fields. Can someone give me or point me to a good example of how to do this? Thanks Jay Hi, Jay Read my answer in the threa...

Referencing client-side JavaScript files?
I have a large site with several subdirectories. I would like to be able to use one master page for the entire site, and not a separate master page for every subdirectory.While trying to accomplish that I ran into an issue with referencing client-side JavaScript files. The ~ character can only be used in sections that have runat="server" specified, and that works fine for eg. CSS files that are referenced like this: <head runat="server">    <title>MasterContentHolder</title>    <link href="~/css/styles.css" rel="stylesheet" type="text/css"...

Client validation using both Javascript and .NET controls
 Hello,I have implemented an online questionnaire. The questionnaire is composed by several textboxes to gather information such as name, organization,email, phone, etc. and a long series of radiobuttonlists and textboxes (text area). These last textboxes need to be filled out only if the user select a specific value in the radiobuttonlists.To perform client validation I used .NET controls to check the format of the first textboxes (name, organization,email, phone, etc. ) and the text areas to ensure that no invalid characters have been entered.To check the all the radiobuttonlist has b...

Web resources about - Comapre two fileds using javascript - asp.net.client-side

JavaScript Kit- Your comprehensive JavaScript, DHTML, CSS, and Ajax stop
Your comprehensive JavaScript, DHTML, CSS, and Ajax stop

Let's Code: Test-Driven Javascript by James Shore — Kickstarter
James Shore is raising funds for Let's Code: Test-Driven Javascript on Kickstarter! A screencast series focusing on rigorous, professional Javascript ...

Eloquent JavaScript: A Modern Introduction to Programming
... and pragmatics. I loved the tutorial-style game-like program development. This book rekindled my earliest joys of programming. Plus, JavaScript! ...

Lightbox (JavaScript) - Wikipedia, the free encyclopedia
On a Lightbox-enabled page, a user can click an image to have it magnified in a Lightbox window, which resizes itself according to the size of ...

Open Directory - Computers: Programming: Languages: JavaScript: Tools: Obfuscators
about dmoz - help Top : Computers : Programming : Languages : JavaScript : Tools : Obfuscators Tools for obfuscation/compression JavaScript code. ...

Facebook File-Transfer App Pipe Relaunches, Now Works Via JavaScript, WebRTC
... allowed Facebook users to send and receive files up to 1 gigabit in size. A new version of Pipe debuted Monday, and the app now works via JavaScript ...

Under the Hood: The JavaScript SDK - The use of polyfills - Facebook
Facebook Engineering hat eine Notiz mit dem Titel Under the Hood: The JavaScript SDK - The use of polyfills geschrieben. Du kannst den vollständigen ...

JavaScript SDK - Facebook-Entwickler
Overview The JavaScript SDK provides a rich set of client-side functionality for accessing Facebook...

Senior Front-End Developer (Javascript and AJAX)
Company: Sometrics Category: Software Development Location: Los Angeles, CA How to Apply: jobs@sometrics.com Description: We are looking for ...

Badass JavaScript (@badass_js) on Twitter
WebGLWorker is an open source library that allows using WebGL from Web Workers. Great work as always from @kripken . blog.mozilla.org/research/2014/… ...

Resources last updated: 12/5/2015 6:09:30 AM