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

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

Javascript validation

Posted By:      Posted Date: October 13, 2010    Points: 0   Category :ASP.Net

how  to write validations for

Phone number

eg: (040)-(12345678)

and alphanumeric

like uppercase & lower case with '   

View Complete Post

More Related Resource Links

decimal value validation and round off by javascript

The article decimal value validation and round off by javascript was added by hiral.hapani on Wednesday, June 02, 2010.

Hi All, I have createdone javascript by which you canvalidate a decimal value of any textbox for which you want. By thisjavascriptwecan bind user to enter only digits in textbox. and when he will enter any decimal value javascript will do round off it

Asp.net Javascript Validation dd/mm/yyyy format


Hi experts,

 I am trying to validate two textbox (fromdate,todate)

should alert a message when Fromdate is more than Todate

I could find only mm/dd/yyyy format in most of google search.

please give me a script or assist how to do this.



Javascript FromDate to Date Validation Help!

Hi,I want to check fromdate and todate in dd/mm/yyyy.The code below mentioned works perfect for single textbox(fromdate) ,but when tried to do for todate(textbox) it doesnot work properly.From Date Should not be greater than ToDate.Please Help.Below is the code:<html><head><title>Date Example</title><script type="text/javascript">    function isValidDate(sText) {        var reDate = /(?:0[1-9]|[12][0-9]|3[01])\/(?:0[1-9]|1[0-2])\/(?:19|20\d{2})/;        return reDate.test(sText);    }    function validate() {        var oInput1 = document.getElementById("txt1");        if (isValidDate(oInput1.value)) {            alert("Valid");        } else {            alert("Invalid!");        }    }</script></head><body>    <P>Date: <input type="

javascript for field validation on a textbox...

I'm looking at doing the validation for the email in javascript since we have asp.net 1.1. I can get it to just alert fine, but once I add the return validation it doesn't fire. Me.ImageButton2.Attributes.Add("onclick", "return validation(this);") <script language="JavaScript"> <!-- function validation () { var test=""; test = document.ticketForm.emailAddress.value; if (test == "xyz") { alert(test); return false; // validation failed } --> </script>

radiobutton validation using javascript

hi' i have two radiobuttons and a button.On button click i have to validate whether the radiobutton is selected or not. I tried the following,but it is not working.pls help.<asp:RadioButton  runat="server" ID="rbyes" Text="Yes"  visible="true" GroupName="a"  /> <asp:RadioButton  runat="server" ID="rbno" Text="No" visible="true" GroupName="a" /> <asp:Button  ID="btnOk" runat="server" Text="OK" OnClick="btnOk_Click"  OnClientClick="return selectRadioButton();"/>function selectRadioButton(){var y=document.getElementById("ctl00_ContentPlaceHolder1_rbyes");var n=document.getElementById("ctl00_ContentPlaceHolder1_rbno");if(y.checked==false && n.checked==false){alert(Please select Yes/No");return false;}return true;}

Validation is not working in Custom List Form using JavaScript ddwrt:GenFireServerEvent()

Hii am creating custom New form for a list using sharepoint designer. i have added the below button for sumbit<input name="Submit1" type="submit" value="Submit" onclick="javascript: {ddwrt:GenFireServerEvent('__commit;__redirect={http://myserver/Lists/VTest/AllItems.aspx}')}" />                <xsl:text xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:nbsp-preserve="yes" disable-output-escaping="yes">&amp;nbsp;                                    </xsl:text><input name="Submit2" type="submit" value="Cancel" onclick="javascript: {ddwrt:GenFireServerEvent('__redirect={http://myserver/Lists/VTest/AllItems.aspx}')}" />the problem is the validation is not working properly. it submits the page without entering values for the required fields.particularly the validation is not working for DateFields.let me know what is the problem here. is it a Bug?muthu

Delaying clientside validation Javascript


For performance reasons, I usually put all my javascripts at the end of my html page.

However, Html.EnableClientValidation() always generates client side validation script after the form in the middle of the document

Is there anything I can do to change this?

What if the MVC team add a DEFER attribute to the generated javascript validation script

so the generated script should like

<script type="text/javascript" defer="defer">
if (!window.mvcClientValidationMetadata) { window.mvcClientValidationMetadata = []; }

validation group creation using javascript


Hi I want to create a validation group using javascript.

How can I do that? 

beginner validation: jquery vs javascript vs codebehind




I've a webform that has around 10 textboxes that are filled with information from an event trigered by combobox.  so far so good.  The thing is that I need  that some textboxes should be validated against the sum of values of others,  and according to that assign given values.  Other textboxes should have a value according to those sum and datefield values.  I haven't found validation controls for asp.net so I assume that I should to it with javascript or jquery.  My concern as asp.net beginner is what happens if the user disables javascript?  If I make it with codebehind I'll have to refresh the page many times as I have many controls to validate.  What can I do ?


thanks in advance.



time in am/pm javascript validation.



I have a time range such as 12:00 am to 11.59 pm,

now in two text boxes i want that no body can go beyond this range how can i achieved it through java script

please help....

Javascript validation


Hi there I m confused about how to validate data at time editing data with gridview, I converted all fields of gridview into template so in code it can be seen textboxes as TextBox1,TextBox2.....now i attached  javascript function with update button. right now I am having error so please have a look at code and reply javascript code to access textbox in gridview in editmode

 function validateData(TextBox2) {
        var sta = false;
            var gridViewID = "<%=GridView_courses.ClientID %>";
        var gridView = document.getElementById(gridViewID);
        var gridViewControls = gridView.getElementsByTagName("TextBox");

        for ( i = 0; i <= gridViewControls.length - 1; i++)

           if (gridViewControls[i].type == "text") {
                if (gridViewControls[i].value == " " || gridViewControls[i].value == null) {

                    sta = true;
                    alert("Error in input");

                if (sta == true) {
                    alert('Quantity must be greater than 0');
                    return false;
                else {

                    return true;


ASP.Net and Javascript validation hack



Suppose i use Javascript validation in my web site, now i save that page and modify the validation code and then post the data, is it possible or not? If yes then how we prevent our website from this type of hacking?

Javascript Date Validation



I have a few Date validations to perform. I have the following columns "BirthDate","College Review Date", "Project Review Date" created in the custom list. In the Column Date and Time format option, I had choosen "Date Only" format.

I want to do some javascript validations on the date created. For example, BirthDate must be less than or equal to System Date. If the users selects a day greater the System Date, I want to alert the user. The alert should be provided after the date selection has changed, and not on the "OK" button click.

How to achieve this using javascript?

Thank you

javascript validation problem?


Hi i want to validate and display an error message using javascript when a user enters less than 12 characters and below is my code

<script language="javascript" type="text/javascript">
function validateElements()
var username=document.getElementById('TextBox2').value;
document.getElementById('Label1').innerText="Userid Less than 12 characters";
return false;

<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="javascript:return validate();" />

but when i press the button nothing is happened,help me with this??

validation in javascript calender


i need to put certain valdiation in calender ,selected data should not less than current date ,so far just just date selected but no valdiation

Arrival Date: 
                                                <asp:TextBox ID="txt_arrival_date"  runat="server"></asp:TextBox>
                                                <a href="javascript:calendar_window=window.open('calendar.aspx?form1=form1.txt_arrival_date','calendar_window','width=554,height=488');calendar_window.focus()">


<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="calendar.aspx.vb" Inherits="gfln1.calendar_aspx" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
     <script runat="server">
Private Sub Calendar1_SelectionChanged(sender As Object, e As EventArgs)
    Dim strjscript As String = "<script language=""javascript"">"
        strjscript &= "window.opener." & _

W3C Validation for XHTML 1.0 Strict with Custom Attributes (Javascript "triggers")?


I've searched high and low on this issue, finding so-called "solutions" involving custom DTD's, using alternate valid attributes in an element to substitute for the invalid attributes, to doing nothing at all about the issue. I want to see what the experts here think.

The problem is that I'm using a 3rd-party control that adds several custom attributes (to act as javascript triggers) to a <td> tag (and one for a <div> tag also). So whenever I try to validate my page against the W3C's validator for XHTML 1.0 Strict, I get errors. Having the 3rd-party control supplier fix their controls is pretty much out of the question (very slow to respond, if ever), so it's something I'll need to deal with myself. The rest of the pages on my site all validate, and the control in question is the very last obstacle to complete validation. Not validating isn't an option I'm ready to consider.

So, any ideas?


ASP.NET, HTML, JavaScript Snippet Support (VS 2010 and .NET 4.0 Series)

This post covers another useful improvement in VS 2010 - HTML/ASP.NET/JavaScript snippet support. Snippets allow you to be more productive within source view by allowing you to create chunks of code and markup that you can quickly apply and use in your application with a minimum of character typing.

Visual Studio has supported the concept of "snippets" for VB and C# in previous releases - but not for HTML, ASP.NET markup and JavaScript. With VS 2010 we now support snippets for these content types as well.
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