Drone
Drone

Reputation: 1134

How to make input text as untouch by javascript

I am trying to remove red border after making empty input-box,

How can I make this.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" id="test" value="123" required="required">
<input type="button" value="Click me" onClick="$('#test').val('');">

Upvotes: 3

Views: 541

Answers (2)

Jayesh Chitroda
Jayesh Chitroda

Reputation: 5049

Add this css:

Check in firefox, you will get result;

:not(output):-moz-ui-invalid {
    box-shadow: 0 0 0 1px black;
}

:not(output):-moz-ui-invalid {
    box-shadow: 0 0 0 1px black;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" id="test" value="123" required="required">
<input type="button" value="Click me" onClick="$('#test').val('');">

Upvotes: 3

Mantas Čekanauskas
Mantas Čekanauskas

Reputation: 2228

Need to apply some css

<style>
    input:required {
    box-shadow:none;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" id="test" value="123" required="required">
<input type="button" value="Click me" onClick="$('#test').val('');">

Upvotes: 1

Related Questions