Hi Guys - I know this is not exactly CF but I'm tr...
# cfml-general
m
Hi Guys - I know this is not exactly CF but I'm trying to change the css of a select box on error to red and the message but whatever Im trying its not having any effect - It is a CF project btw - just using jquery to validate 🙂 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.7.0/jquery.validate.js"></script> <form id="demographicsform" action="?action=mergeDashboardDemograpphics" method="post"> <div class="row-liquid"> <p class="span4"> <label for="corpID">Select Client</label> <select name="corpID" id="corpID" class="required"> <option value="">None</option> <cfloop query="getCorps"> <option value="#getCorps.id#"> #getCorps.label# (#getCorps.id#)</option> </cfloop> </select> </p> </div> <input type="submit" /> </form> <script> $("##demographicsform").validate({ messages: { corpID: { required: "Please select an option from the list!", }, } }); </script>
a
There is a #javascript room if you haven't spotted it. jQuery validate adds CSS classes so does your CSS have anything for those classes?
Looking at the jQuery validate demo then it's adding a class of 'error' to the form field
So just add input.error { border: 1px solid red }
m
@aliaspooryorik Thanks 🙂 Where do I add input.error { border: 1px solid red } ? Is it in the JQuery itself or the form ?
Ive done that you see but to no avail so just want to check if I have not placed it correctly
a
In your CSS file
m
<style> input.error { border: 1px solid red }; </style>
Thats what I have
I pinched the code from here and adapted to mine 🙂 http://jsfiddle.net/Kn3v5/
a
something like this: http://jsfiddle.net/rcnupme3/1/
m
Perfect 🙂 Thanks @aliaspooryorik