0

I have a view where I have a textbox where the user can enter url and process the request. What I want to do is to include client side validation that the url is in a proper format. Here is what I have:

<fieldset>
<p>
  <%=Html.Label("Please enter URL:") %>
<%=Html.TextBox("url")%>
<%= Html.ValidationMessage("url", "*") %>
<input type="submit" value="Crawl" />
</p>
</fieldset>

Any advice how I can include client side validation for that piece of code? Thanks in advance, Laziale

Laziale
  • 7,965
  • 46
  • 146
  • 262
  • What framework are you using for client side validation? – Darin Dimitrov Sep 12 '11 at 16:47
  • Hey I would take a look at this link. [Client side validation][1] [1]: http://stackoverflow.com/questions/6869661/client-side-validating-dynamically-generated-form-elements-in-mvc-3-0 – Postonoh Sep 12 '11 at 16:52

1 Answers1

0

Use regexular expression attribute in your model to validate the url.

Than, if you are using the jquery unobtrusive validation, the rest is taken care of by the framework

For mvc2 validation done client-side try taking a look to this post also

Iridio
  • 9,213
  • 4
  • 49
  • 71