473,385 Members | 1,312 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.

button attributes disable validation

I am trying to use both validation controls and to add submit button
attributes, but when I add the button attributes, the javascript fpr the
validation controls is no longer created for the page. How can I use both?

Thank you,

Tim Meagher
Nov 19 '05 #1
4 1593
Hi Tim,

If I understand you correctly, you are trying to add javascript to the
submit button and it breaks client-side validation. If that's the case, see
this article: http://aspalliance.com/699 in the topic "Messageboxes and
Validation". While it shows how to add a confirm prompt, you can use the
technique shown to add any javascript to a button.

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"Tim Meagher" <ti*********@pfm.org> wrote in message
news:Oa****************@TK2MSFTNGP15.phx.gbl...
I am trying to use both validation controls and to add submit button
attributes, but when I add the button attributes, the javascript fpr the
validation controls is no longer created for the page. How can I use
both?

Thank you,

Tim Meagher

Nov 19 '05 #2
Peter,

Thank you for this information. It has shown me how to invoke the
validation objects when the submit button is pressed as part of the server
side event handler - and it appears that the validation should be added to
server-side handling especially for browsers that cannot handle client-side
validation.

I would still be interested in knowing how to run the client-side validation
in conjunction with the confirm feature that I added to my submit button to
avoid a postback.

Regards,

Tim

"Peter Blum" <PL****@Blum.info> wrote in message
news:Oj**************@TK2MSFTNGP11.phx.gbl...
Hi Tim,

If I understand you correctly, you are trying to add javascript to the
submit button and it breaks client-side validation. If that's the case, see this article: http://aspalliance.com/699 in the topic "Messageboxes and
Validation". While it shows how to add a confirm prompt, you can use the
technique shown to add any javascript to a button.

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"Tim Meagher" <ti*********@pfm.org> wrote in message
news:Oa****************@TK2MSFTNGP15.phx.gbl...
I am trying to use both validation controls and to add submit button
attributes, but when I add the button attributes, the javascript fpr the
validation controls is no longer created for the page. How can I use
both?

Thank you,

Tim Meagher


Nov 19 '05 #3
Hi Peter,

I also found out that one can selectively enable and disable client side
validation merely by setting the enable flag of the validation control to
true or false. I was able to take advantage of that in my code to simplify
validation for all my validation controls by creating the two following
methods:

// Returns true if validation succeeds for the given validation control, or,

// if the control is not enabled (in which case no validation should occur)

private bool IsValidControl(BaseValidator control)

{

if (!control.Enabled)

{

return true;

}

control.Validate();

return (control.IsValid);

}

private bool IsValidForm()

{

bool valid = true;

valid &= IsValidControl(ReqValUserID);

valid &= IsValidControl(RegexUserID);

valid &= IsValidControl(ReqValFirstName);

valid &= IsValidControl(RegexFirstName);

valid &= IsValidControl(RegexMiddleInitial);

valid &= IsValidControl(ReqValLastName);

valid &= IsValidControl(RegexLastName);

valid &= IsValidControl(ReqValEmail);

valid &= IsValidControl(RegexEmail);

valid &= IsValidControl(ReqValPhone);

valid &= IsValidControl(RegexPhone);

valid &= IsValidControl(ReqValNotes);

valid &= IsValidControl(ReqValReject);

return valid;

}

Finally, I invoked the IsValidForm() method in my submit button onclick
handler as follows:

if (!IsValidForm())

{

return;

}
Tim

"Peter Blum" <PL****@Blum.info> wrote in message
news:Oj**************@TK2MSFTNGP11.phx.gbl...
Hi Tim,

If I understand you correctly, you are trying to add javascript to the
submit button and it breaks client-side validation. If that's the case, see this article: http://aspalliance.com/699 in the topic "Messageboxes and
Validation". While it shows how to add a confirm prompt, you can use the
technique shown to add any javascript to a button.

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"Tim Meagher" <ti*********@pfm.org> wrote in message
news:Oa****************@TK2MSFTNGP15.phx.gbl...
I am trying to use both validation controls and to add submit button
attributes, but when I add the button attributes, the javascript fpr the
validation controls is no longer created for the page. How can I use
both?

Thank you,

Tim Meagher


Nov 19 '05 #4
Hi Tim,

You wrote:
I would still be interested in knowing how to run the client-side
validation
in conjunction with the confirm feature that I added to my submit button
to
avoid a postback.
I'm confused by this. I pointed you to a portion of my article that
specifically handles client-side confirm that either permits or blocks
submitting the page.

FYI: This is easier in my Professional Validation And More. I give you
properties to create confirm messages and run the confirm either before or
after page validation runs on the client side. I also give you a hook to add
any other javascript you want into the page validation process so you can
stop the page from submitting for your own reasons.

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"Tim Meagher" <ti*********@pfm.org> wrote in message
news:O7**************@TK2MSFTNGP09.phx.gbl... Peter,

Thank you for this information. It has shown me how to invoke the
validation objects when the submit button is pressed as part of the server
side event handler - and it appears that the validation should be added to
server-side handling especially for browsers that cannot handle
client-side
validation.

I would still be interested in knowing how to run the client-side
validation
in conjunction with the confirm feature that I added to my submit button
to
avoid a postback.

Regards,

Tim

"Peter Blum" <PL****@Blum.info> wrote in message
news:Oj**************@TK2MSFTNGP11.phx.gbl...
Hi Tim,

If I understand you correctly, you are trying to add javascript to the
submit button and it breaks client-side validation. If that's the case,

see
this article: http://aspalliance.com/699 in the topic "Messageboxes and
Validation". While it shows how to add a confirm prompt, you can use the
technique shown to add any javascript to a button.

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"Tim Meagher" <ti*********@pfm.org> wrote in message
news:Oa****************@TK2MSFTNGP15.phx.gbl...
>I am trying to use both validation controls and to add submit button
> attributes, but when I add the button attributes, the javascript fpr
> the
> validation controls is no longer created for the page. How can I use
> both?
>
> Thank you,
>
> Tim Meagher
>
>



Nov 19 '05 #5

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

Similar topics

4
by: Tim Meagher | last post by:
I am trying to use both validation controls and to add submit button attributes, but when I add the button attributes, the javascript fpr the validation controls is no longer created for the page. ...
2
by: buran | last post by:
Dear ASP.NET Programmers, I have a web user control (a search menu) which has 2 validation controls (one for input and another for the search criterion). I am including this search user control...
1
by: anoop | last post by:
Hello, How can I include the source file in "Button.Attributes("Onclick")="javascript: my javascript commands " command as I do in <script> tag in javascript as"src=abc.js" in .aspx page...
2
by: Andy G | last post by:
Quick question. I have numerous validation controls on a web form. I also have a cancel button on the web form that Response.Redirect("previouspage.aspx"), but when you click the button all of...
1
by: Bruce | last post by:
I use btnSave.Attributes.Add("onclick", "ShowMessage()") to link my web control button to a JavaScript function. It works well until I added a Validation control into the page. After that,...
1
by: s.chelliah | last post by:
Hi, I am trying to use javascript, div tag and radio button to disable/enable a text box. It works fine in netscape and firefox, but in IE, the text box is not disabled when the user checks the...
2
by: bay_dar | last post by:
Hi, I have an internal ASP.NET application that I'm are using to send e-mails out based on a single milepost or milepost range entered. I'm trying to do two things when a user clicks on the...
1
by: hexagram | last post by:
hi can anybody here help me on my problem the condition is if the form is blank or incomplete or not save the print button is disable, otherwise if the form is fill up complete and saved the...
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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?
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.