Guide on showcasing an icon adjacent to the input fields once they have been validated successfully with the help of jquery plugins

I am struggling with the code below which is supposed to validate the SubmitForm when the button is clicked. It successfully changes the textboxes to red and displays an error message with a symbol if validation fails. However, I am wondering how I can show a different symbol or a text message when the user enters correct details into the text boxes. I am currently using the jQuery Validation plugin available at this link.

Example.html

<fieldset id="fieldset1">
    <legend>Registration Details:</legend>
    <form id="SubmitForm">
        Name of business:<br/>
        <input size="30" type="text" id="businessname" class="required" name="businessname"/><br/>               
        Zipcode:<br>
        <input size="30" type="text" id="zipcode"  class="required zipcode" name="zipcode"/><br>              
        Telephone:<br/>
        <input size="30" type="text" id="telephone"  class="required phone"  name="telephone"/><br/>
        Email:<br/>
        <input size="30" type="text" id="email"  class="required email" name="email"/>
</fieldset>
<br/>
Your email is your User Name:<br/>
<input size="30" type="text" id="username" class="required" name="email"/><br/>
Choose Password:<br/>
<input size="30" type="text" id="pass" class="required password" class="required" name="password"/><br/>
Retype Password:<br/>
<input size="30" type="text" id="pass1" equalTo="#pass"/><br/>               
<input id="Addresslisting" type="image" src="images/Submit.png" align="left"  />                                
</form>  
</feildset>

Example.js

$(document).ready(function () {
    $("#Addresslisting").click(function () {
        $("#SubmitForm").validate();
    });
});

Example.css

label {
    width: 10em;
    float: left;
}

label.error {
    color: red;
    padding: 8px 200px 0px 0px;
    vertical-align: top;
    float: right;
    background: url("unchecked.gif") no-repeat 120px 0px;
}

input.error {
    border: 1px solid red;
}

input.errorlist {
    margin: 0;
    color: red;
    margin-bottom: 10px;
}

#fieldset1 {
    border: 1px solid #1f76c8;
    width: 500px;
    margin: 5px;
    padding: 10px 15px 5px 15px;
}   

Answer №1

If you want to utilize the success feature, follow this example:

    .validate({         
         success: function(label) {
             label.text("great!").addClass("success"); 
             // This will create a <label class="success">great!</label>
             // Assuming errorElement is set to "label"
         },
        rules: {
            number: {
                required:true,
                minLength:3,
                maxLength:15,
                number:true 
            }

        }
    });

You can check it out here.

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

Is there a never-ending loop caused by a jquery/jqtouch getJSON call?

I'm currently working on my first JQTouch application. I've encountered an issue where, upon transitioning from #login to #home, a JSON ajax call is triggered successfully but it seems that the pageAnimationEnded event gets stuck in an infinite l ...

Mysterious JQuery attribute

I've come across a piece of code that utilizes an unfamiliar selector that I can't seem to figure out: $("div[tag=" + someVariable + "]").css("display", "block"); From what I gather, the selector is searching for a div element with an attribute ...

Implementing a way to send nested objects back in response to a jQuery get request

Using jquery.get() to request data from the Spring-Boot backend: var url = "http://localhost:8080/api/v1/get_holdings?userId=1"; $.get(url, function(payload,status) { if (status == "success") { $.each ...

Issues with AngularJS radio button functionality

Hey there, I am currently using AngularJS in my project. However, when I attempted to add a span to one of my input fields, all the radio buttons related to it stopped functioning. Can anyone offer some suggestions on what might be going wrong here? < ...

Obtaining information from the HttpServletResponse through an AJAX form

In my "first.jsp", there is a form containing hidden input values and pointing to another jsp file. <form id="popupForm" name="popupForm" action="<%= cqRequest.externalizeHref(handle) %>" method="post"> <input type= ...

Using jQuery and JSON data to dynamically populate a second dropdown menu with filtered options

I am working on a form with two drop-down menus and a text box. The first drop-down contains static values, while the second drop-down is populated dynamically from a JSON array. My goal is to filter the options in the second drop-down based on the selecti ...

Unable to modify div style using a JS function

I am attempting to show different divs based on the button clicked, with all starting with a display style of "none" except for one default div called "atualizacoes". After clicking a button, all divs should be set to display="none", and then the specific ...

QUnit and a troubleshooting JSONP situation

I am currently working on testing my web app's ability to handle failure scenarios and display the corresponding error messages using QUnit. One particular scenario I am focusing on is when my Data Source is unavailable during app initialization, res ...

Why is my md-button in Angular Material displaying as full-width?

Just a quick question, I created a simple page to experiment with Angular Material. On medium-sized devices, there is a button that toggles the side navigation, but for some reason, it expands to full width. There's no CSS or Material directives causi ...

Transform gradient backgrounds as the mouse moves

I'm attempting to create a unique gradient effect based on the cursor position. The code below successfully changes the background color of the document body using $(document.body).css('background','rgb('+rgb.join(',')+&a ...

Issue with delayed chaining of class addition and removal in JQuery not functioning as expected

Here is the code snippet: $(document).ready(function () { $('.current-visitors').delay(3000).queue(function () { $(this).addClass('show').delay(1000).queue(function () { $(this).removeClass('sho ...

Showing headings in the table vertically

I have a header1 and header2 with corresponding data1 and data2 that I want to display differently. h h e e a a d d e e r r 1 2 data1 data2 To enhance the presentation, I wish to add borders around the head ...

Retrieve the content of a specific HTML tag using JavaScript

Is it possible to extract the content of a specific HTML tag as a string or XML format? <body> <script src="jquery.min.js"> //var test = document.getElementsByTagName("input"); //alert(test[0]); $(document).ready(function ( ...

The drop-down button unexpectedly disappears when using Bootstrap in combination with jQuery autocomplete

I have some javascript code that is structured like: <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>jQuery UI Autocompl ...

Retrieving data from a textbox using JavaScript within an Excel VBA setting

I'm encountering an issue with a Macro in Excel where I need to retrieve the value of an "input type="text"" on a JavaScript webpage. However, the value is not specified in the code (value=""), and it remains unchanged even when the webpage displays t ...

WordPress CSS Styling Issue: HTML Element Display Problem

I recently converted my static HTML site to WordPress, but I'm facing an issue where the site is always aligned to the left. Despite trying different solutions like the one below: body{ margin: auto; } The original HTML page was centered perfectly ...

How can I render just one event instead of all events when using the eventRender callback function?

I am currently working on adding an event to my calendar using a JSON format with specific attributes like id and start time. Here is what I have tried so far: $('#calendar').fullCalendar('renderEvent', my_event); $('#calendar& ...

In ReactJS with Bootswatch, the font styles are not applied

I have experimented with various methods to apply this font, but it is still not functioning correctly. @font-face { font-family: 'Samim'; src: local('Samim'), url(./resources/fonts/Samim.ttf) format('truetype'); fon ...

The ZK Component fails to display within the HTML tag

In my dilemma, I am attempting to showcase a hyperlink component under an HTML tag along with some instructions for click functionality: <zk> <html> <a label="show me" onClick="@command('showMe')" /> </html> </zk ...

Adjusting div height as you scroll down the page

Hello, I am new to CSS and I have encountered an issue with setting the height of a div element to 100%. When the list on my page exceeds the size of the page, the div is no longer visible when scrolling. Do you have any ideas on how to fix this? Here is t ...