Text alignment validation in jQuery

utilizing the validation capabilities of the jQuery validation plugin

check out: http://jsfiddle.net/Kn3v5/205/

<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.js"></script>
<div>
    <form id="everything">
        <label for="dd1">Select the best option</label>
        <br/>
        <select name="dd1" id="dd1" class="required">
            <option value="">None</option>
            <option value="o1">option 1</option>
            <option value="o2">option 2</option>
            <option value="o3">option 3</option>
        </select>
        <br/>
        <br/>
        <input id="agreement" name="agreement" type="checkbox"><b> I accept the TOS</b>
            <br/>
        <input type="submit" />
</div>
</form>

There are multiple fields which show error messages on their right side. The issue is that the validation message for the checkbox is appearing between the checkbox and its label.

[checkbox]

          [validation message] [label]

Desired layout:

[checkbox] - [label]

[validation message]

Is there a way to achieve this? Your help is appreciated!

Answer №1

Check out this Fiddle where I added float:left to the checkbox and swapped the message with the textbox

 <label  for='agreement'> I agree to the terms and conditions</label>
    <input id="agreement" name="agreement" type="checkbox" style = 'float:left' />

        <br/>
    <input type="submit" />

Answer №2

I found exactly what I was looking for at this link: http://jsfiddle.net/Kn3v5/223/

<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.js"></script>
<div>
    <form id="everything">
        <label for="dd1">Choose the best option</label>
        <br/>
        <select name="dd1" id="dd1" class="required">
            <option value="">None</option>
            <option value="o1">Option 1</option>
            <option value="o2">Option 2</option>
            <option value="o3">Option 3</option>
        </select>
        <br/><br/>
        <label for='agreement'>I agree to the Terms of Service</label>
        <input id="agreement" name="agreement" type="checkbox" style='float:left' />
        <br/>
        <div id="everything2"></div>
        <input type="submit" />
    </form>
</div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Bootstrap icon issue: square displaying instead of the intended icon

I am currently in the process of creating a responsive website using Bootstrap 3. I have successfully downloaded and imported Bootstrap 3 into the root directory of my website. However, I have encountered an issue where the icon does not display correctly ...

Having trouble understanding why the jQuery script is not communicating effectively with the ASP.NET web API

Whenever I attempt to execute this script, a 500 error pops up. My setup consists of a demo project in asp.net mvc4 with a petite web api controller and the default home controller. Below is my API controller: namespace MyTrainingApi.Controllers { public ...

Ignoring the partial view's click action

Within my parent view, there is a partial view containing two pseudo buttons: thumb up and thumb down, along with a paragraph containing assigned classes. Despite setting up two functions to execute when 'ready', the partial view does not respon ...

My divs are multiplying twice as fast with every iteration of the Javascript For Loop

Recently, I developed a script that generates a series of fields based on a number provided by the user (k). Initially, I had a script that would create the correct number of fields. However, I decided to arrange them like vectors on the screen, so I made ...

Modifications to the toolbar styling are made by the Angular Material mat-form-field

Having some trouble creating an input field in my component alongside a mat-toolbar element. When I try to insert a mat-form-field, it ends up messing with the styling of the mat-toolbar. I've been unable to pinpoint exactly where the issue lies (if ...

Generate a Safari-compatible Bookmark URL that is functional

I've attempted to use the JavaScript "AddFavorite" function in my code, but unfortunately, it's not functioning properly in Safari. It seems to work in IE and perhaps Firefox from what I can recall, but all my efforts to make it work in Safari ha ...

Exploring the implementation of if/else statements in Sass/HTML

I need assistance with customizing the appearance of a save button on my form. The button is currently disabled and appears in blue color, but I would like it to change to a different color until all fields within the form are completed. Even though it c ...

The submit button in Selenium Firefox does not have an onClick event attached

My form includes a submit button coded like this: <input type="submit" class="btn btn-info pull-right save_button" id="save_button" value="Save"/> With the help of JQuery, I add an onclick event to trigger a confirmation box: $('body').o ...

Avoiding a line break between two <form> tags is essential for maintaining the structure of your webpage

I am looking for a way to ensure that there are no line breaks between two forms that I have on my website. Here is the code snippet: <form action="..."> <input type="submit" /> </form> LINE BREAK HERE <form action="..."> <inpu ...

Interacting with jQuery mouse events on elements below the dragged image

I'm attempting to create a drag-and-drop feature for images using jQuery. While dragging, I generate a thumbnail image that follows the mouse cursor. However, this is causing issues with detecting mouseenter and mouseleave events on the drop target pa ...

Link a distinctive number to a specific element

I am searching for a method to link a DOM element with a distinct number that is not assigned to any other element in the DOM. Using an Id attribute is not an option as not all elements possess such an identifier. One potential approach is to obtain a num ...

How to remove an event listener that was added within a function in JavaScript?

I am encountering an issue while trying to remove an event listener that was created inside a function. Oddly enough, it works perfectly when I move the event listener outside of the function. See the example below: <body> <div id='myDiv&apo ...

Stop Chrome from highlighting the canvas section

One interesting feature of our whiteboard application is that Chrome users have the ability to highlight the entire canvas by dragging their mouse in a specific manner: Do you have any suggestions on how we can prevent this behavior? Thank you! ...

Levitating with Cascading Style Sheets

Looking for some assistance to troubleshoot my code. I am trying to make the hover color apply only to the navigation bar and not affect the pictures. I attempted to solve this by specifying .a.main-nav:hover { ...}, but it ended up removing the hover effe ...

Is there a conflict between bootstrap.min.JS and chart.min.js?

I have been working on developing an admin page for customer support and I recently added a visually appealing chart to display some data on the home screen. The chart integration was successful, but when I introduced tab panes to the page and refreshed ...

Issue with Jquery Forms Plugin jqXHR response in Internet Explorer versions 8 and 9

I encountered a peculiar problem that only seems to occur in IE8 and 9, despite testing on Safari, Chrome (on Mac), Firefox (on PC), as well as IE versions 10 and above. Below is the code snippet causing trouble: $('#fileStore_newUpload').ajaxF ...

Ensure that the tab's content fills up the entire space provided and prevent the need for a vertical scrollbar to appear

Is there a way to make the tab content take up 100% of the available space without causing a vertical scroll due to the height of the tab itself? I am currently using ng-bootstrap and need assistance with this specific issue. You can review my code in the ...

Enhancing the appearance of an Angular.js application

On the same page, there are two buttons - one for buying and one for selling. It appears that both buttons share the same HTML instance. This creates a problem when trying to style them individually using classes, ids, or other HTML-targeted selectors, as ...

Consistent word spacing across several lines

Can someone help me with an issue I'm facing? It seems simple, but I can't seem to figure it out. I am looking for a way to maintain consistent spacing between words on multiple lines without using tables. Essentially, I want something like invi ...

As I enlarge the font size, the border around the div also expands

Can someone explain why the size of the div border increases along with the font size? If you'd like to see an example, check out this link to a jsFiddle: LINK TO JS FIDDLE: http://jsfiddle.net/krishna22211/m14qms52 ...