Link to home
Start Free TrialLog in
Avatar of mikha
mikhaFlag for United States of America

asked on

javascript/jquery user input validation in asp.net mvc

I have a form in  razor view (see sample code below). In the form tag, i have specified controller action method, that will be called when form is posted. I want to validate user input, when user clicks on search button. and if there are any errors in user input, prevent the form posting and display errors.

I can create a javascript/jquery function to check for user input validation. how should i call the this function and how can i prevent the form submission, if there are any errors?


--default.cshtml
 <form id="defaultForm" method="post" action="controllerMethod">

<input type="submit" id="searchBtn" value="Search" />
......
</form>
 <script type="text/javascript">
</script>
SOLUTION
Avatar of HainKurt
HainKurt
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial