What is this error in JavaScript?

Hi there

this is my JSfiddle.net
http://jsfiddle.net/vngx/v71ejn2y/9/

When I select any value other than “Select Course” in first

The page is trying to submit to the jsfiddle address which it can’t do.

alert('Data is:'+data'+'Data 2 is:'+data2');

Remove extra ’ after data

Text of Both Select is not displaying

although single value is working

Here is one more thing

this is my jsFiddle.net
http://jsfiddle.net/vngx/v71ejn2y/17/

I want to add some validation When a User Do not select any values from Course ,Branch at that time I want to set some custom messages in front of them.

How do I acheive this?

You don’t need to select input by id like that: $("input[id='sub']")
Here is simplier way to do that: $("input#sub")

And you have extra apostrophe again:

alert('Data is:'+data+'Data 2 is:'+data2');
                                        ^

Pay attention to syntax highlighting to avoid that errors.

Make hidden div with error message and show it when validation isn’t passed.
HTML:

<div class="error">Error!</div>

jQuery:

$('.error').show();

Also you need to return false if you want to prevent from submission.

Thanks @megazoid

Ok

as your suggestion I have updated in jsfiddle.net
http://jsfiddle.net/vngx/v71ejn2y/15/

There is one more problem error message are displaying in next line I want them to be on same line

Can I solve this problem my using JQuery Custom Rules?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.