1

hi all i want to know that can we validate a control which is out side a form element in asp.net(server side validation)and outside a form element in html(client side validation) let's take a closer look

<html>
<body>
<input type="text"  name="first name"/>
</body>
</html>

can we apply clien side validation on above text box by java script ?

in asp.net

<form runat="server">
</form>

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

here i have written textbox after the form will it validate at server side ?

1
  • Validating this on server side is a bit of a oddity, as it will not be posted back, as it is not in the form? Commented Sep 6, 2010 at 14:16

2 Answers 2

2

Last time I checked, it wasn't valid HTML to have form elements, such as inputs, outside a form.

In any case, it won't work on the server-side because ASP.NET does not know the textbox exists. I could see it working client-side, but I have never tried this as it makes no sense.

What are you trying to achieve here? There is likely a better solution.

Sign up to request clarification or add additional context in comments.

1 Comment

but sir it's working well in any browser ? i means when we apply only client side validation then need not necessary to keep it inside form afterall i am not sending data on server side for validation ?
-1

Sure, if you set the input to runat the server and give it an ID:

<input type="text"  name="first name" runat="server" id="myserversideid"/>

You can then use the validation controls as you would normally

2 Comments

i am talking about 2nd on i means asp.net not on html ?
acording to you if i write any asp contro out side form then it will not run on server ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.