1

I am trying to validate a simple login form using HTML, CSS and javascript.

Here is my jsfiddle for the same.

For testing purpose I am trying to just give a alert message

function validate() {
  alert('testAlert');
}

But when i run the fiddle it gives the following error.

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

What is the problem in my code.Any help?

Thanks in advance.

0

1 Answer 1

2

Two changes need to be implemented.

First change the javascript from onLoad to body. The options are available in the javascript pane on clicking the JAVASCRIPT

Secondly since there is a submit button, you need to prevent the default behaviour. Use ajax to submit the form

function validate(e) { //changed here
  e.preventDefault(); // changed here
  alert('testAlert');
}


<form method="POST" onsubmit="return validate(event);"> // changed here
  // rest of the code 
</form>

DEMO

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.