壳牌形式不验证JSFiddle [英] Shell Form Does Not Validate JSFiddle

查看:136
本文介绍了壳牌形式不验证JSFiddle的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行这个JSFiddle时,我得到了这个冗长的错误: http://jsfiddle.net/YqENs/

  {error:Shell form does not validate {'html_initial_name':u'initial-js_lib','form ':< mooshell.forms.ShellForm object at 0xa965bac> ;,'html_name':'js_lib','html_initial_id':u'initial-id_js_lib','label':u'Js lib','field':< django .forms.models.ModelChoiceField object at 0xaaeb76c> ;,'help_text':'','name':'js_lib'} {'html_initial_name':u'initial-js_wrap','form':< mooshell.forms.ShellForm对象在0xa965bac> ;,'html_name':'js_wrap','html_initial_id':u'initial-id_js_wrap','label':u'Js wrap','field':< django.forms.fields.TypedChoiceField object at 0xa9f82cc> ,'help_text':'','name':'js_wrap'}} 

代码(w / html):

 <!DOCTYPE html> 
< html>
< head>
< script>
函数greeting()
{
document.getElementById(p1)。innerHTML = document.forms [frm1] [fname] .value;
}
< / script>
< / head>

< body>

你叫什么名字?< br>
< form name =frm1onsubmit =greeting()method =post>
< input type =textname =fname>
< input type =submitvalue =提交>
< / form>

< p id =p1>< / p>

< / body>
< / html>


解决方案

我猜问题是从提交你不认为你真的想在那里加载一个新页面,所以试试: onsubmit =greeting(); return false;来调用你的函数,但是停止表单提交事件。

否则,提交操作会尝试重新加载页面 - jsFiddle不太喜欢这个页面。

I am getting this lengthy error when I run this JSFiddle: http://jsfiddle.net/YqENs/

{"error": "Shell form does not validate{'html_initial_name': u'initial-js_lib', 'form': <mooshell.forms.ShellForm object at 0xa965bac>, 'html_name': 'js_lib', 'html_initial_id': u'initial-id_js_lib', 'label': u'Js lib', 'field': <django.forms.models.ModelChoiceField object at 0xaaeb76c>, 'help_text': '', 'name': 'js_lib'}{'html_initial_name': u'initial-js_wrap', 'form': <mooshell.forms.ShellForm object at 0xa965bac>, 'html_name': 'js_wrap', 'html_initial_id': u'initial-id_js_wrap', 'label': u'Js wrap', 'field': <django.forms.fields.TypedChoiceField object at 0xa9f82cc>, 'help_text': '', 'name': 'js_wrap'}"}

Here is the code(w/html):

<!DOCTYPE html>
<html>
<head>
<script>
function greeting()
{
document.getElementById("p1").innerHTML=document.forms["frm1"]["fname"].value;
}
</script>
</head>

<body>

What is your name?<br>
<form name="frm1" onsubmit="greeting()" method="post">
<input type="text" name="fname">
<input type="submit" value="Submit">
</form>

<p id="p1"></p>

</body>
</html>

解决方案

I guess the problem is the from submitting, I don't think you actually want to load a new page there, so try: onsubmit="greeting(); return false;" to call your function but stop the form submit event.

Otherwise the submit action will try and reload the page -- which jsFiddle is not liking very much.

这篇关于壳牌形式不验证JSFiddle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆