Anonymous557402

Hi,

I have a page on one of my projects that is an email form with the four following fields:

Sender's Name - (Required)

Sender's Email Address - (Required)

Subject - (Not Required)

Body - (Required)

I wanted to use Javascript to display a confirm message that asks the user if they are sure they want to leave the subject blank when sending the email. To do this I inserted the following into the OnClientClick property of my Send button:

return confirm('Send this email without a subject ')

With all of the fields blank, I clicked send and the javascript message I created above is displayed.

The problem: The validation for my three required fields is ignored and if I confirm that I'd like to send the email without a subject the email sends with no information in any of the fields.

Question: Is is possible to make the validation take priority over the OnClientClick property to check and see if the required fields are populated first If it's not possible are there any suggestions as to how I can deal with this problem

I know I could solve this by simply making all of the fields required, but I'd like to give the user the option of leaving the subject line blank. Any help is greatly appreciated!



Re: Visual C# General OnClientClick Priority?

Johnny_2010

you can change"<input type='submit' >" to "<input type='button'>"

if the button's type is "submit",it will submit the data to server.so other feilds will be clear!





Re: Visual C# General OnClientClick Priority?

Johnny_2010

i think you can change the button's type "submit" to "button".

because if the button's type is submit.it will submit to server when you click it,and other feilds will be clear.





Re: Visual C# General OnClientClick Priority?

Johnny_2010

try

change your code

"<input type="submit">" to "<input type="button">".

because if the button's type is submit, it will be submit the data when you click the button. and other feilds will be clear.