473,387 Members | 1,711 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.

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 17 '05 #1
7 3097
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 17 '05 #2
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 17 '05 #3
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 17 '05 #4
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 17 '05 #5
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 17 '05 #6
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 17 '05 #7
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 17 '05 #8

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: techfuzz | last post by:
I scoured this group and others looking for the best way to disable a button after the first click to prevent multiple submissions, but never did find anything that worked like they said it would. ...
3
by: Jeff | last post by:
I need to intercept the Click event of a asp:Button on the client side so that i can disable it after they've clicked it... HOW can i do this?? I was thinking of making the button an HTML button...
7
by: nicholas | last post by:
how can I disable a button when the user clicks on it and the webform is validated. I want this to prevent the user from clicking twice and by this submitting the form twice. Thank you. ...
4
by: Dmitry Korolyov [MVP] | last post by:
When we use btnSubmit.Attributes = "javascript: this.disabled=true;" to make the button disabled and prevent users from clicking it again while form data still posting, there is no longer...
2
by: Niclas Lindblom | last post by:
Hi, I have a datagrid with linkbuttons. I would like to catch the click event when a link button has been clicked and use the string from the text value of the link button in a clientside Java...
3
by: Jeff | last post by:
I have a payment form with a submit button. A large percentage of users double-click the submit button thus submitting their payment information twice. I would like to use javascript to disable...
5
by: | last post by:
Hi all, Has anyone been able to write some custom javascript on the onclick event of submit button to do certain things like disable submit button, only submit form once etc. This was a breeze...
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...
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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.