EzDevInfo.com

input interview questions

Top input frequently asked interview questions

Why does the jquery change event not trigger when I set the value of a select using val()?

<select id="single">
    <option>Single</option>
    <option>Single2</option>
</select>

<script>
$(function() {
    $(":input#single").change(function(){
    /* This logic is not being run when value is set by val(), but does run when user selects a value with their mouse */
    }
});

$("#single").val("Single2");
</script>

Source: (StackOverflow)

Python: user input and commandline arguments

How do I have a Python script that can accept user input (assuming this is possible) and how do I make it read in arguments if run from the command line?


Source: (StackOverflow)

Advertisements

Can I hide the HTML5 number input’s spin box?

Is there a consistent way across browsers to hide the new spin boxes that some browsers (such as Chrome) render for HTML input of type number? I am looking for a CSS or JavaScript method to prevent the up/down arrows from appearing.

<input id="test" type="number"/>

Source: (StackOverflow)

Is there any way to change input type="date" format?

I'm working with HTML5 elements on my webpage. By default input type="date" shows date as YYYY-MM-DD.

The question is, is it possible to change it's format to something like: DD-MM-YYYY?


Source: (StackOverflow)

Best way to remove an event handler in jQuery?

I have an input type="image". This acts like the cell notes in Microsoft Excel. If someone enters a number into the text box that this input-image is paired with, I setup an event handler for the input-image. Then when the user clicks the image, they get a little popup to add some notes to the data.

My problem is that when a user enters a zero into the text box, I need to disable the input-image's event handler. I have tried the following, but to no avail.

$('#myimage').click(function { return false; });

Source: (StackOverflow)

How to remove the border highlight on an input text element

When an html element is 'focused' (currently selected/tabbed in to), many browsers (at least Safari and Chrome) will put a blue border around it.

For the layout I am working on, this is distracting and does not look right.

<input type="text" name="user" class="middle" id="user" tabindex="1" />

FireFox does not seem to do this, or at least, will let me control it with

border: x;

If someone can tell me how IE performs, I would be curious.

But getting Safari to remove this little bit of flare would be nice.

Thanks


Source: (StackOverflow)

HTML input - name vs. id

When using the HTML <input> tag, what is the difference between the use of the name and id attributes especially that I found that they are sometimes named the same?


Source: (StackOverflow)

JavaScript get input text value

I am working on kinda a search with JavaScript, I would use a form but it messes up something else on my page. I have this input text field:

<input name="searchTxt" type="text" maxlength="512" id="searchTxt" class="searchField"/>

and this is my JavaScript:

<script type="text/javascript">
function searchURL(){
    window.location = "http://www.myurl.com/search/" + (input text value);
}
</script>

How do I get the value from the text field into JavaScript?


Source: (StackOverflow)

Disable validation of HTML5 form elements

In my forms, I'd like to use the new HTML5 form types, for example <input type="url" /> (more info about the types here).

The problem is that Chrome wants to be super helpful and validate these elements for me, except that it sucks at it. If it fails the built-in validation, there's no message or indication other than the element getting focus. I prefill URL elements with "http://", and so my own custom validation just treats those values as empty strings, however Chrome rejects that. If I could change its validation rules, that would work too.

I know I could just revert back to using type="text" but I want the nice enhancements using these new types offers (eg: it automatically switches to a custom keyboard layout on mobile devices):

So, is there a way to switch off or customise the automatic validation?


Source: (StackOverflow)

How to remove border (outline) around text/input boxes? (Chrome) [duplicate]

This question already has an answer here:

Can anyone explain how to remove the orange or blue border (outline) around text/input boxes? I think it only happens on Chrome to show that the input box is active. Here's the input CSS I'm using:

input {
    background-color: transparent;
    border: 0px solid;
    height: 20px;
    width: 160px;
    color: #CCC;
}

enter image description here


Source: (StackOverflow)