Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
612 views
in Technique[技术] by (71.8m points)

javascript - Shell Form Does Not Validate 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>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...