473,387 Members | 3,787 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,387 software developers and data experts.

Problem with ClientSide Validations

I am doing client side validation. I am writing a javascript to do this.
The Javascript is :
Expand|Select|Wrap|Line Numbers
  1. script language="javascript" type="text/javascript">
  2.   function validate()
  3.   {
  4.         var CName=document.getElementById("<%=txtCustName.ClientID%>").value;
  5.         var Addr=document.getElementById("<%=txtAddress.ClientID%>").value;
  6.         var Phone=document.getElementById("<%=txtPhone.ClientID%>").value;
  7.  
  8.         if(CName.length<1)
  9.         {
  10.             alert('Please Enter Customer Name'); 
  11.             return false;
  12.         }
  13.  
  14.         if(Addr.length<1)
  15.         {
  16.             alert('Please Enter The Address');
  17.             return false;
  18.         }
  19.  
  20.         if(Phone.length<1)
  21.         {
  22.             alert('Please Enter The Phone Number');
  23.             return false;
  24.         }
  25.     return true;
  26.   }
  27.   </script>
  28.  
at HTML source and I am calling this function at the onclientclick event of submit button.
I am not getting error. I even get the message box for CName and Address, but the control goes to submit button and the blank space gets saved.
for City it even wont show the message also.
What would be the reason can anybody please tell me.
Mar 24 '09 #1
1 955
tlhintoq
3,525 Expert 2GB
TIP: When you are writing your question, there is a button on the tool bar that wraps the [code] tags around your copy/pasted code. It helps a bunch. Its the button with a '#' on it. More on tags. They're cool. Check'em out.
Mar 24 '09 #2

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

Similar topics

0
by: Rajesh Jain | last post by:
I Have 2 separate schemas. --------------Schema 1 is defined as below----------- <xs:schema targetNamespace="http://Schemas/1" xmlns="http://Schemas/1" xmlns:xs="http://www.w3.org/2001/XMLSchema"...
3
by: Lyn | last post by:
Hi, I am developing a project in which I am checking for records with overlapping start/end dates. Record dates must not overlap date of birth, date of death, be in the future, and must not...
2
by: Avad | last post by:
I have a following screen. The login is a "user control" with validations controls in it. This side I have address book in which "name" is required field. But when I click on "add new user" the...
4
by: Alphonse Giambrone | last post by:
I have a simple login page that has two text boxes, two requiredfieldvalidators, a couple of labels and a button. It has been reduced down to almost nothing to troubleshoot the below problem. ...
1
by: Anoj Kumar | last post by:
Hi All , I am facing very strange kind of problem. I am using few validation controls ( requiredfield validation, and regexvalidation) on a form. I've set the validion to occour at the client...
3
by: Tarun Upadhyaya | last post by:
Hi, I am facing strange problem I read Scott mitchell's article about ASP.NET and javascript at ...
5
by: Dany C. | last post by:
We have install a valid SSL certificate issued to www.mycompany.com on our web server running IIS 6.0 / win2003 SP1. Then we have created a sub domain pointing to the same server for our web...
5
by: Segfahlt | last post by:
I need a little help here please. I have 2 win forms user controls in 2 different projects that I'm hosting in 2 different virtual directories. The controls have been test and operate okay in...
1
by: Anup | last post by:
In my form I and doing validations using 'Javascript' as I m using ASP1.1 and there is very less support for Validators there. //Code Behind private void Page_Load(object sender,...
2
by: swethak | last post by:
hi , i write the code in .htm file. It is in cgi-bin/searches/one.htm.In that i write a form submitting and validations.But validations are not worked in that .htm file. I used the same code in my...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.