Hi, I'm fairly new to MVC & HTML so if some of my terminology is wrong, apologies...
I have an MVC 3 View which has a form on it. Instead of using a standard <input> submit button I've got an anchor <a> tag styled up to be a graphical looking button. I've hooked up the click event to a JavaScript function...
cw_dev
Member
16 Points
5 Posts
Client Side Validation with Anchor as submit
Feb 20, 2012 01:39 PM|LINK
Hi, I'm fairly new to MVC & HTML so if some of my terminology is wrong, apologies...
I have an MVC 3 View which has a form on it. Instead of using a standard <input> submit button I've got an anchor <a> tag styled up to be a graphical looking button. I've hooked up the click event to a JavaScript function...
jQuery('#NextStepButton').click(function () { NextStepButtonClick(); });
This function calls submit on the form...
<script type="text/javascript">
function NextStepButtonClick() {
document.forms[0].submit(); }
</script>
While this works normally, on this particular page it's not validating client side unobtrusive.
So a normal <input> submit button works, but changing it to an <a> tag instead and calling this JavaScript function to submit the page does not.
Is it possible to call client side validation this way?
bruce (sqlwo...
All-Star
36836 Points
5443 Posts
Re: Client Side Validation with Anchor as submit
Feb 20, 2012 03:06 PM|LINK
use the jquery submit
$('#NextStepButton').click(function () { $('form:first').submit(); });cw_dev
Member
16 Points
5 Posts
Re: Client Side Validation with Anchor as submit
Feb 20, 2012 03:48 PM|LINK
Thanks!