I am getting this lengthy error when I run this JSFiddle: /
{"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 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>
Share
Improve this question
asked Sep 23, 2013 at 5:32
user2805835user2805835
1731 silver badge4 bronze badges
1
- 1 Heya, welcome to Stack Overflow. Please, when asking a question, include details from your research and your debugging, be specific about the problem. Note that you can edit your question to update it. – Jeroen Commented Sep 23, 2013 at 5:35
2 Answers
Reset to default 10I 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.
I had a similar problem and the accepted answer did not work. The reason was my onsubmit function did not compile as it had an error in it. For whatever reason the error is lost and it gives a message about validation which is totally misleading.
UPDATE: Quite frankly I found it a lot easier to ditch jsfiddle and use a flat html file to get to the bottom of the form submission problem.