Automatically detect and remove http:// from input using javascript [closed] - javascript

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I have one/many HTML inputs that are to be used for URL entry
<input></input>
<input></input>
What I would like is: When an entry is made, then http:// is stripped from the beginning of that input. For example if http://google.com is entered then it becomes google.com in the input instead.
How does one go about achieving this with Javascript (or jQuery)? I haven't tried anything because I don't know where to begin. Pointers to documentation and/or examples would be greatly appreciated.

Get the value of the input and use regexp to replace http:// from the value.
$('input').change( function() {
var input = $('input');
input.val(
$('input').val().replace(/https?:\/\//gi,'')
);
});
DEMO
UPDATE
Xotic750 has a fiddle with 6 different methods for removing http://
http://jsfiddle.net/Xotic750/kyKsK/
I also updated my code to support the possibility of https:// as well.

Related

how to detect if a #hash tag is being entered in and input element [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
My question is simple:
How do I make the use of JavaScript regex to detect whether a #hashtag is being entered in the input element? I have a function to convert the hashtag into a clickable link but it's PHP. I want a similar function but in jQuery the reason is that if a hashtag is entered then I can send a value to the PHP processor form.
Sorry there is no code as I dont know much about JavaScript regex, also, I could not find any good tutorials.
You are looking for this: (#\w*)
function hasNonStandard(inputElem) {
return /[#\w*]/.test(inputElem.value);
}

How to secure SSN field while entering on a webform [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
When entering the SSN on the webform, I need the digit to appear for a couple of seconds and then have it go to an asterisk.
Is this possible? Please provide directions.
you can try something which is suggested here:
http://css-tricks.com/better-password-inputs-iphone-style/
there are 2 examples, one flashes the last digit entered, while keeping the textbox as asterisk. other example keeps everything as asterisk except the last digit.
The trick to this is changing the input type from text to password in the input's change event, with a setTimeout if needed. See this fiddle for a simple example using jquery.

form is not working, I used HTML5 & bootstrap 3.0? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
form is not working, I used HTML5 & bootstrap 3.0?
here i add the link of the site please checkout.
I cant figure-out it.
http://www.deliveryguys.in/html/index.html
It's usually best to post snippits of code that you think are malfunctioning but in this case I think you should invest in a spellchecker.
I went to
http://www.deliveryguys.in/html/index.html
And it seems to work fine.
Notice it's HTML instead of HMTL
Edit: OK now I see the real problem with your code
The form is underneath other HTML elements. You need to give your stylings z-indexes in order to control what is on top of what. I gave the form a z-index of 1000 and it worked fine. I suggest editing your css classes to include z-indexes to give you finer control than that.
Please note that your form action has been mapped to "#"
Kindly point the form action to the appropriate server page & it will start working.
Regards
SRIRAM NATARAJAN
(Chennai, Tamil Nadu, India)
(www.thesriram.co.in)

unidentified javascript function [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I've been handed a role administering a SharePoint site, and the following custom code is on one of the pages:
<script type="text/javascript">
$(document).ready(function() {
$("#pgtitle").html("Customer Service Feedback");
});
</script
I'm not a javascript guy, so I'm having trouble interpreting this. The code was written by someone who is no longer with my firm, and left well before I arrived.
$(document).ready(function() means that the code that follows, will start as soon as the page has loaded.
$("#pgtitle").html("Customer Service Feedback"); simply passes the value Customer Service Feedback to the HTML element pgtitle.
if you look on the page for the pgtitle element, I'm sure you will see it contains the text Customer Service Feedback ! :)
It sets text on the element of id = pgtitle as soon as the DOM document had fully loaded. In human language it manually sets the value of some title.
Have a look at the JQuery library for the "html" method and if you look for the id that is called "pgtitle" you will find the html that is effected.
Source:http://api.jquery.com/html/

document.getElementById disabled in ASP.NET site [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I found a nice site that build in ASP.NET. I want to try some things on it, like entering text into input field through console, with JavaScript, but it looks like it disabled. when I try to do:
document.getElementById("name");
I get null, on each element I try it. In the js files of site I see they are using getElementById in the code, but somehow it's disabled for me.
You need to use clientId. For example here is your server control
<asp:textbox id="txtName" runat="server/>
and now you want to access that with javascript then you need to do following.
document.getElementById("<%=txtName.ClientID%>").value;

Categories