I have a html form ,where I have text fields and select box .now I want to do the following:
If any of the fields is null then an error message will be shown beside the fields which are null(and not on a alert box) .How will I do it?
Also using references such as document.forms["f1"]["fl_no"] for DOM elements is old-fashioned and fragile. A more modern approach is to assign id values to the elements and use document.getElementById().
To create the error messages you can create DOM elements on the fly and inject them into the DOM at the appropriate places.
All of that would be far easier using a library such as jQuery to help you.
(In fact, the jQuery validation plugin handles it all for you and would be far less work.)
Joined: Aug 09, 2010
I started using the jquery validation plugin but I am facing the folloe=wing problems
1)I have 1 text field("flno") and 2 select boxes("src" and "dest") ,now if I select the "flno " I dont need to use the other select boxes ,else the select boxes become mandatory.
2)What shall I do to check that the values in select boxes are never equal,is there something like notequalTo rule?
For something that specific you'd like need to write a custom rule function for the validator.
1)I wrote a custom method to check the value of to fields should not be equal
and then I add this method to rule of field2 element ...but it does not work!!
2) I tried using required( dependency-callback ) to check that if a textfield value is not selected then a selectbox field would become mandatory,else it would be optional,so I used the following and this does not work as well
3)Is it mandatory that the name and id field of the input boxes should be same to get it validated?