Is it possible to modify the color of an input tag in a form when it is selected?

I'm currently developing a contact form for my website with bootstrap. The form automatically scrolls to any unfilled required field when the user clicks submit, and highlights it with a blue border. However, I want the border color to change to red instead. How can I make this adjustment?

Answer №1

To customize the border style, you can add a class and specify the desired border style.

if ($("#frm").validationEngine('validate')) {
// Add validation criteria as needed

// If the value is null, add a class to change the border color and focus on the field
// For example, if the field name is 'firstname'
if ($('#firstname').val() == "") {
$('#firstname').addClass("required");
$('#firstname').focus();
}

}
.required
{
border-color: red;
background: white;
}
<form name="frm">
<input type="text" name="firstname" id="firstname" placeholder="ENTER NAME">
</form>

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

How can I prevent a nested Table from inheriting the style of the parent table?

Just to clarify, I'm not using tables or any other styling methods like that on my page. I have a simple table that lists services, prices, and PayPal buttons for adding to the cart. While everything is functioning properly and looks good, there are ...

The typography components within material-ui are appearing side by side on the same row

I'm having an issue with my typography components appearing on the same line instead of two separate lines. I've tried various methods to fix it but nothing seems to work. <div class="center"> <Typography variant=&q ...

Is it possible to include all the information in a form submission, not just the inputs?

I have a problem with submitting the form and accessing all the variables I need. When I check the $_POST variable, I only see the values of the form inputs. Is there a way to also send other variables like the content of multiplicator1? How can I achiev ...

What is the best way to smoothly scroll to another page using a specific id?

My website consists of multiple pages and I am looking for a code that will allow for smooth scrolling navigation to another page when loading on a specific id or section. For example, in the navbar I have multiple pages with links. When clicking on a lin ...

jQuery Mobile elements remain resident in the memory

I'm currently working on a jQuery mobile app that includes a chart created with Highcharts, which can be exported using CanVG and canvas2ImagePlugin. However, I've noticed that the chart object remains in memory. As a result, if the page is opene ...

Bring in the content to Notepad utilizing jQuery

How can I export data to Notepad? I have fields for Name, Age, and WorkingStatus that are input as text and textarea. Is there a demo or code available to help me insert this data into Notepad? ...

Utilize PHP's IF/ELSE statements to showcase the outcome

In my problem, I have a sample code. What I aim to achieve is to notify the user if there is no data that matches the input they provided, specifically when searching for "Helloworld". I am considering using an if-else statement for validation to determine ...

Tips for Rearranging Columns Using Bootstrap 4

In my Bootstrap 4 project, I have utilized the following HTML tags. <div class="container"> <div class="row align-items-center"> <div class="col-md-3"> <div class=&q ...

What could be causing the significant gap at the bottom of my Flexbox?

Whenever I resize the page to fit a mobile device, there is always a large gap at the bottom. I want the content to stack normally when it shrinks, without leaving a huge gap at the bottom. There is no gap at the bottom when viewed on desktop, but as soo ...

Increasing margin and padding by a factor of two, achieved through the utilization of float and

Whenever I apply float or inline-block to elements, I notice that their margin or padding appears to be doubled. For example, the margin between the middle and bottom sections is set to 5%. However, the size of the top section is also 5%, but it is only ha ...

Pulling out a particular row from an HTML table with the help of HTML::TreeBuilder

I am a beginner in perl programming and I am facing a major challenge. I need to parse an HTML file that contains a single table, and extract a specific row based on one of its column entries. Here is a snippet of the HTML file: many previous rows descri ...

Is there a way to ensure that the div of my template spans 100% in width and height?

I'm attempting to make my div 100% in size but I am having trouble achieving it. Here is my code: <template> <div> <Navbar/> <Calendar/> </div> </template> <script setup> import Calendar from &apos ...

When utilizing Xpath, it consistently triggers the Python <li> element as the first child

I am attempting to click on multiple links with the following code: self.browser.find_element_by_xpath("//li[@onclick[contains(text(),"+origin_iata_code+")]]").click() The origing_iata_code is from this list: ['FLL', 'MCO', 'AFL ...

Merge two separate arrays to create a new associative array

I'm faced with the challenge of merging two arrays of data obtained from an HTML form. The first array (payment_descriptions) is structured as follows: ["1st Desc","2nd Desc","3rd Desc"] While the second array (payment_ ...

Expanding the Bootstrap Utility class within an SCSS stylesheet

Utilizing Bootstrap's utility classes in my scss file has been a recent experiment of mine. For instance: .pageTitle { @extend .p-3, border-bottom: 1px solid red} My current approach to importing Bootstrap involves using this code: @import '~b ...

What is the method for obtaining the WordPress user ID?

I am looking to incorporate a Twitter follow button for all site authors on every post. Below is the structure of the Twitter button: <a href="https://twitter.com/twitterapi" class="twitter-follow-button" data-show-count="false" data-lang="en">Foll ...

Customizing the main icon in the Windows 10 Action Center through a notification from Microsoft Edge

I am facing an issue with setting the top icon of a notification sent from a website in Microsoft Edge. Let's consider this code as an example: Notification.requestPermission(function (permission) { if (permission == "granted") { new ...

Shift attention to the subsequent division after a correct radio option or text input has been submitted

I need to enhance the user experience on my form. When a user interacts with specific elements like hitting enter in a text input or clicking a radio button, I want to automatically focus on the next "formItem" division. My form structure is organized as ...

Swap out a portion of HTML content with the value from an input using JavaScript

I am currently working on updating a section of the header based on user input from a text field. If a user enters their zip code, the message will dynamically change to: "GREAT NEWS! WE HAVE A LOCATION IN 12345". <h4>GREAT NEWS! WE HAVE A LOCATIO ...

Achieving a centered layout for a div containing two photos that overlap on a mobile screen resolution

I attempted to center a div containing 2 photos perfectly in the center, but encountered some issues. Despite trying various positioning techniques such as display: flex, align-items, justify-content, and more, I couldn't get the image container to mo ...