Do not show default value of the input field

Anuket

I have an input field

 <input id='spe_count' type="text" placeholder="number" class="form-control" data-original-title="" title="">

and as I need it to be by default with value -1 I am assigning it with jQuery

 $("#spe_count").val('-1');

And I get this input field and see this value -1 inside it, but what I want is that this input is with value -1, but on the page it would be empty or with placeholder. And when I am changing values, I'd like to do so, that deleting value, emptying the box means that it is default value -1 (not typing minus one , but simply deleting all the values mean this is minus one)

Is this possible?

R A Khan
#("#spe_count").click(function(){
    var value= $(this).val();
    if(value.length < 1){
       $(this).attr("value", -1);
    }
});

The above code will serve your purpose.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Default value if input field empty

How do i calculate input value on change and also it should show the default value result?

How to show the input field value in another input field using reactjs?

Show default value for editing on Python input possible?

How to unescape a default value of an input field in Thymeleaf?

Default value in input field lost after click

To set default prefix value for input field

How to add a default value for an input field

on dropdown select value show hidden input field

show input field value in div using javascript

Input text field do not show on browser - Django

how do I show result in an input field?

How do I add a default value to Confluence Cloud Macro input field?

How do I display value in input field

How to get value from input field modal bootstrap and show the value to another input field in the same modal with jquery?

How to show default value in b-form-input? in Vue

Setting default value for a datetime-local input field in Blade

I want to overwrite value in field input with default attribute

Django Form Wizard - Setting default value for text input field

Want to set default value of Input field via JavaScript

How can I set a default, but changeable, value to an input field?

Override migration default value in Rails form input field

Vue.js datepicker not allowing the update of default value of input field

React - How to reset input field(controlled) to default value

R shiny: how to clear an input field with a default value using shinyjs?

Codeigniter: The default value of a text input field if data is not returned from the controller

How to make an input field mandatory with a default value already present in angular?

how to use field.label as default value in a text-input

Java Selenium delete default input field value and add own values