473,385 Members | 2,162 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.

JS validation doesnt work when NET build-in validators are used

I am frustrated by the issue, and looking for a workaround.

I have a dropdown list, and a button and some other controls on the page.
When the button is clicked, I need to ensure a valid dropdown list item is
selected, (e.g. selectedIndex > 0, as the 1st item in ddl is dummy record).
Also, I need use some NET build-in validators for other controls.

What I did is:

- Create a JS function
function submitForm() {
if ( (document.getElementById("ddl").selectedIndex <= 0)) {
alert("nothing selected in ddl");
return false;
}

if (typeof(Page_ClientValidate) == 'function')
Page_ClientValidate();

if (Page_IsValid){
ValidatorOnSubmit();//this will fire postback
}
}

- on the server side add attributes to button.
btnSubmit.Attributes.add("onClick","submitForm()")
I wonder if anyone can help me out. Thanks.

Jul 19 '05 #1
2 2429
Sean,

Use the required field validator instead of the javascript you wrote. The
required field validator has a property, "InitialValue", set that property
equal to the initial text in your dropdown and that will solve your problem.

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Sean" <ss****@yahoo.com> wrote in message
news:eo*************@TK2MSFTNGP12.phx.gbl...
I am frustrated by the issue, and looking for a workaround.

I have a dropdown list, and a button and some other controls on the page.
When the button is clicked, I need to ensure a valid dropdown list item is
selected, (e.g. selectedIndex > 0, as the 1st item in ddl is dummy record). Also, I need use some NET build-in validators for other controls.

What I did is:

- Create a JS function
function submitForm() {
if ( (document.getElementById("ddl").selectedIndex <= 0)) {
alert("nothing selected in ddl");
return false;
}

if (typeof(Page_ClientValidate) == 'function')
Page_ClientValidate();

if (Page_IsValid){
ValidatorOnSubmit();//this will fire postback
}
}

- on the server side add attributes to button.
btnSubmit.Attributes.add("onClick","submitForm()")
I wonder if anyone can help me out. Thanks.


Jul 19 '05 #2
There's a detailed discussion by Mike Moore on this issue:

http://www.aspalliance.com/kenc/faq6.aspx
"Sean" <ss****@yahoo.com> wrote in message
news:eo*************@TK2MSFTNGP12.phx.gbl...
I am frustrated by the issue, and looking for a workaround.

I have a dropdown list, and a button and some other controls on the page.
When the button is clicked, I need to ensure a valid dropdown list item is
selected, (e.g. selectedIndex > 0, as the 1st item in ddl is dummy record).
Also, I need use some NET build-in validators for other controls.

What I did is:

- Create a JS function
function submitForm() {
if ( (document.getElementById("ddl").selectedIndex <= 0)) {
alert("nothing selected in ddl");
return false;
}

if (typeof(Page_ClientValidate) == 'function')
Page_ClientValidate();

if (Page_IsValid){
ValidatorOnSubmit();//this will fire postback
}
}

- on the server side add attributes to button.
btnSubmit.Attributes.add("onClick","submitForm()")
I wonder if anyone can help me out. Thanks.


Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title>...
6
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: ...
0
by: Libs | last post by:
I have a custom validator that validates a numeric field, txtField, that allows for thousand separators. I also placed a validation summary so that it would display the error msgs of all my...
4
by: PCH | last post by:
I've run into a big problem with Opera 7x users. It appears that most pages do not render the panels correctly, and form validation does not fire at all. I tracked down some threads about the...
4
by: nkle004 | last post by:
I am using following function to check for my input my input is like 0.00 i dont want to allow any specialcharacters. function numericValidation() { var x = this; var reg = new...
1
by: Matthias Langbein | last post by:
Hi, I wondered whether anybody knows how XML-Schema-Validation with the common SAX-Parsers work. Do they require to build a DOM-Tree before processing and validate, or do they handle validation...
1
by: dfalconer | last post by:
I have a vb.net site which has a form on it using Client Side Validation. This works fine on my local machine (Windows XP Pro, IIS 5.1), fine on our staging server (Windows 2003 SP1, IIS 6)....
1
by: oiref | last post by:
I need a simple validation rule to make sure that data conforms to this format:letter letter letter number number number number. ive tried all the obvious codes eg like"lll9999" but Access refuses...
3
by: jx2 | last post by:
hi guys i would appriciate your coments on this code - when i ran it for the very first time it doesnt see @last = LAST_INSERT_ID() but when i ran it next time it read it properly i need to know it...
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: 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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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.