access validation info in client script

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.

Advertisements

On Feb 23, 4:48 am, "Velvet" <> 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.

Advertisements

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.

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) athttp://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

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

"Walter Wang [MSFT]" <> wrote in message
news:...
> 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 (, 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.
>

I spoke too soon... Still not quite right, but now I have a direction.

Thanks!

"Velvet" <> wrote in message
news:%...
> 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]" <> wrote in message
> news:...
>> 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 (, 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.
>>
>
>

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.

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!

"Velvet" <> wrote in message
news:...
>I spoke too soon... Still not quite right, but now I have a direction.
>
> Thanks!
>
> "Velvet" <> wrote in message
> news:%...
>> 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]" <> wrote in message
>> news:...
>>> 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 (, 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.
>>>
>>
>>
>
>

==================================================
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.

==================================================
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.

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!