【问题标题】:load exteral form into html div and try to on submit with validation but its not working将外部表单加载到 html div 并尝试通过验证提交,但它不起作用
【发布时间】:2014-01-23 21:13:00
【问题描述】:
onclick =id(myModalssid) 用于将 html(external_form_fields.html .formval) 文件特别调用到 div(.modal-body-id) 中。该 div 包含表单,我需要在提交时验证表单。
<script>
$('#myModalssid').click(function ()
{
$('.modal-body-id').load('external_form_fields.html .from_val');
alert('Message');
});
</script>
【问题讨论】:
标签:
javascript
jquery-ui
jquery
【解决方案1】:
在 jQuery 中创建函数进行验证,
并在您的点击事件中调用该函数...
就像:--
<script>
$('#myModalssid').click(function () {
$('.modal-body-id').load('external_form_fields.html .from_val');
alert('dgfdfgs');
formValidation();
});
function formValidation()
{
//Your validation Process...
}
</script>
【解决方案2】:
表单加载时需要初始化验证脚本:
$('#myModalssid').click(function ()
{
$('.modal-body-id').load('external_form_fields.html .from_val', function() {
$('.form').on('submit', function() {
//your validation script
});
});
});