Home All Groups Group Topic Archive Search About

access validation info in client script

Author
22 Feb 2007 11:48 PM
Velvet
Does anyone know a way to force the client script to preform a client-side
validation for controls in validation groups?

What is currently happening is I have two validation groups (Billing,
CreditCard).  The validation doesn't happen until the submit button is
pressed and the server validation happens.  I added an OnClickClient event
to the submit button that pops up a comfirm box, but it pops before any
validation happens.

What I would like to do is validate the form with client script and if it's
valid, then pop up the credit card charge confirmation box.  Once that's
confirmed then run the server-side validation.

Any one have any ideas or know of an article out there?

Thanks!

Author
23 Feb 2007 6:33 AM
Zeba
Show quote
On Feb 23, 4:48 am, "Velvet" <MSDNNospam...@nospam.nospam> wrote:
> Does anyone know a way to force the client script to preform a client-side
> validation for controls in validation groups?
>
> What is currently happening is I have two validation groups (Billing,
> CreditCard).  The validation doesn't happen until the submit button is
> pressed and the server validation happens.  I added an OnClickClient event
> to the submit button that pops up a comfirm box, but it pops before any
> validation happens.
>
> What I would like to do is validate the form with client script and if it's
> valid, then pop up the credit card charge confirmation box.  Once that's
> confirmed then run the server-side validation.
>
> Any one have any ideas or know of an article out there?
>
> Thanks!

I'm not sure I got you right, and Im rather hesitant to respond as I'm
new to .net & JS myself, but can't you just give a call to a
javascript validate function in the onSubmit . If the validation
succeeds you can give a confirmation box (at the end of the function).
If validation fails or user clicks cancel return false. Else return
true.

Zeba
Author
23 Feb 2007 7:23 AM
Walter Wang [MSFT]
Hi Velvet,

You could create a javascript function and assign it to the form's onsubmit
handler. In this way, this javascript function will be called before
submitting the form, if you return false, the form will not be submitted;
and if the page didn't pass client-side validation, the onsubmit will not
be fired.

#Followers of the IHttpHandler : No more hijacking of __doPostBack in
Whidbey
http://weblogs.asp.net/vga/archive/2004/03/01/NoMoreHijackingOfDoPostBackInW
hidbey.aspx

#onsubmit Event (FORM)
http://msdn2.microsoft.com/en-us/library/ms536972.aspx


Sincerely,
Walter Wang (waw***@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Author
23 Feb 2007 4:18 PM
Velvet
Adding my confirm box to the form instead of the button worked great and was
the simple solution!  Thanks!

Form.Attributes.Add("onclick", "if(!confirm('Your credit card will be billed
for " + totalPrice.ToString("C") +

" for this order.')){return false;}");

Velvet



Show quote
"Walter Wang [MSFT]" <waw***@online.microsoft.com> wrote in message
news:sETieuxVHHA.1540@TK2MSFTNGHUB02.phx.gbl...
> Hi Velvet,
>
> You could create a javascript function and assign it to the form's
> onsubmit
> handler. In this way, this javascript function will be called before
> submitting the form, if you return false, the form will not be submitted;
> and if the page didn't pass client-side validation, the onsubmit will not
> be fired.
>
> #Followers of the IHttpHandler : No more hijacking of __doPostBack in
> Whidbey
> http://weblogs.asp.net/vga/archive/2004/03/01/NoMoreHijackingOfDoPostBackInW
> hidbey.aspx
>
> #onsubmit Event (FORM)
> http://msdn2.microsoft.com/en-us/library/ms536972.aspx
>
>
> Sincerely,
> Walter Wang (waw***@online.microsoft.com, remove 'online.')
> Microsoft Online Community Support
>
> ==================================================
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
> ications. If you are using Outlook Express, please make sure you clear the
> check box "Tools/Options/Read: Get 300 headers at a time" to see your
> reply
> promptly.
>
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
> http://msdn.microsoft.com/subscriptions/support/default.aspx.
> ==================================================
>
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
Author
23 Feb 2007 4:20 PM
Velvet
I spoke too soon...  Still not quite right, but now I have a direction.

Thanks!

Show quote
"Velvet" <MSDNNospam216@nospam.nospam> wrote in message
news:%23jqT8Y2VHHA.1036@TK2MSFTNGP03.phx.gbl...
> Adding my confirm box to the form instead of the button worked great and
> was the simple solution!  Thanks!
>
> Form.Attributes.Add("onclick", "if(!confirm('Your credit card will be
> billed for " + totalPrice.ToString("C") +
>
> " for this order.')){return false;}");
>
> Velvet
>
>
>
> "Walter Wang [MSFT]" <waw***@online.microsoft.com> wrote in message
> news:sETieuxVHHA.1540@TK2MSFTNGHUB02.phx.gbl...
>> Hi Velvet,
>>
>> You could create a javascript function and assign it to the form's
>> onsubmit
>> handler. In this way, this javascript function will be called before
>> submitting the form, if you return false, the form will not be submitted;
>> and if the page didn't pass client-side validation, the onsubmit will not
>> be fired.
>>
>> #Followers of the IHttpHandler : No more hijacking of __doPostBack in
>> Whidbey
>> http://weblogs.asp.net/vga/archive/2004/03/01/NoMoreHijackingOfDoPostBackInW
>> hidbey.aspx
>>
>> #onsubmit Event (FORM)
>> http://msdn2.microsoft.com/en-us/library/ms536972.aspx
>>
>>
>> Sincerely,
>> Walter Wang (waw***@online.microsoft.com, remove 'online.')
>> Microsoft Online Community Support
>>
>> ==================================================
>> Get notification to my posts through email? Please refer to
>> http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
>> ications. If you are using Outlook Express, please make sure you clear
>> the
>> check box "Tools/Options/Read: Get 300 headers at a time" to see your
>> reply
>> promptly.
>>
>> Note: The MSDN Managed Newsgroup support offering is for non-urgent
>> issues
>> where an initial response from the community or a Microsoft Support
>> Engineer within 1 business day is acceptable. Please note that each
>> follow
>> up response may take approximately 2 business days as the support
>> professional working with you may need further investigation to reach the
>> most efficient resolution. The offering is not appropriate for situations
>> that require urgent, real-time or phone-based interactions or complex
>> project analysis and dump analysis issues. Issues of this nature are best
>> handled working with a dedicated Microsoft Support Engineer by contacting
>> Microsoft Customer Support Services (CSS) at
>> http://msdn.microsoft.com/subscriptions/support/default.aspx.
>> ==================================================
>>
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
>>
>
>
Author
23 Feb 2007 5:26 PM
Velvet
This seems to work a bit better:

ButtonFinish.OnClientClick = "if(Page_ClientValidate()){if(!confirm('Your
credit card will be billed for " + totalPrice.ToString("C") + " for this
order.')){return false;}}";
This is on the button I wanted to use for submit.  I have two other buttons
on the page and the onclick for the form would pop my confirm message for
the other two buttons as well.  I tried setting the UseSubmitBehavior to
false, hoping that would keep the buttons from causing the submit, but it
didn't.

So Instead I found the js file that is specified in this article:

http://aspalliance.com/699#Page4

I then found the validation call for the client side script and used it in
the OnClientOnclick before the confirmation button.  This works like a
charm!

Note: I did NOT make any changes to the JS file as the article suggests.

Thanks again!

Show quote
"Velvet" <MSDNNospam216@nospam.nospam> wrote in message
news:eGMyaa2VHHA.1016@TK2MSFTNGP04.phx.gbl...
>I spoke too soon...  Still not quite right, but now I have a direction.
>
> Thanks!
>
> "Velvet" <MSDNNospam216@nospam.nospam> wrote in message
> news:%23jqT8Y2VHHA.1036@TK2MSFTNGP03.phx.gbl...
>> Adding my confirm box to the form instead of the button worked great and
>> was the simple solution!  Thanks!
>>
>> Form.Attributes.Add("onclick", "if(!confirm('Your credit card will be
>> billed for " + totalPrice.ToString("C") +
>>
>> " for this order.')){return false;}");
>>
>> Velvet
>>
>>
>>
>> "Walter Wang [MSFT]" <waw***@online.microsoft.com> wrote in message
>> news:sETieuxVHHA.1540@TK2MSFTNGHUB02.phx.gbl...
>>> Hi Velvet,
>>>
>>> You could create a javascript function and assign it to the form's
>>> onsubmit
>>> handler. In this way, this javascript function will be called before
>>> submitting the form, if you return false, the form will not be
>>> submitted;
>>> and if the page didn't pass client-side validation, the onsubmit will
>>> not
>>> be fired.
>>>
>>> #Followers of the IHttpHandler : No more hijacking of __doPostBack in
>>> Whidbey
>>> http://weblogs.asp.net/vga/archive/2004/03/01/NoMoreHijackingOfDoPostBackInW
>>> hidbey.aspx
>>>
>>> #onsubmit Event (FORM)
>>> http://msdn2.microsoft.com/en-us/library/ms536972.aspx
>>>
>>>
>>> Sincerely,
>>> Walter Wang (waw***@online.microsoft.com, remove 'online.')
>>> Microsoft Online Community Support
>>>
>>> ==================================================
>>> Get notification to my posts through email? Please refer to
>>> http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
>>> ications. If you are using Outlook Express, please make sure you clear
>>> the
>>> check box "Tools/Options/Read: Get 300 headers at a time" to see your
>>> reply
>>> promptly.
>>>
>>> Note: The MSDN Managed Newsgroup support offering is for non-urgent
>>> issues
>>> where an initial response from the community or a Microsoft Support
>>> Engineer within 1 business day is acceptable. Please note that each
>>> follow
>>> up response may take approximately 2 business days as the support
>>> professional working with you may need further investigation to reach
>>> the
>>> most efficient resolution. The offering is not appropriate for
>>> situations
>>> that require urgent, real-time or phone-based interactions or complex
>>> project analysis and dump analysis issues. Issues of this nature are
>>> best
>>> handled working with a dedicated Microsoft Support Engineer by
>>> contacting
>>> Microsoft Customer Support Services (CSS) at
>>> http://msdn.microsoft.com/subscriptions/support/default.aspx.
>>> ==================================================
>>>
>>> This posting is provided "AS IS" with no warranties, and confers no
>>> rights.
>>>
>>
>>
>
>
Author
26 Feb 2007 7:51 AM
Walter Wang [MSFT]
Hi Velvet,

Instead of calling Page_ClientValidate() directly in your script, you
should be able to achieve the same objective by simply doing:

<script language="javascript" type="text/javascript">

function mySubmit()
{
if (!confirm('Your credit card will be billed for " +
totalPrice.ToString("C") + " for this order.")) {
return false;
}
return true;
}

</script>

<form onsubmit="return mySubmit();" ...>


But of course this only works in ASP.NET 2.0 since then we changed
__doPostBack to check for onsubmit before submitting the form.

Regards,
Walter Wang (waw***@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Author
1 Mar 2007 2:24 AM
Walter Wang [MSFT]
Hi Velvet,

I am interested in this issue. Would you mind letting me know the result of
the suggestions? If you need further assistance, feel free to let me know.
I will be more than happy to be of assistance.

Have a great day!

Regards,
Walter Wang (waw***@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

AddThis Social Bookmark Button