0

How can i validate content of a input box? that when a user for example write in that inbox http://www.example.com input box turn it into www.example.com .in other words its valide frist http and if its exist remove it automatically and insert the correct and show the correct in that input-box ?

6
  • 1
    What do you have so far? Commented Jun 23, 2012 at 10:56
  • i want a solution for this can u help me more ? Commented Jun 23, 2012 at 10:59
  • i dont want its shows an alaramm i want if the http typed its removed autmaticly plz tell me about that function Commented Jun 23, 2012 at 11:00
  • I think you have to invest a bit more time lookin for a solution on your own, I mean the answer to this question can be found on Google pretty easily. Commented Jun 23, 2012 at 11:04
  • 1
    javascript regular expression, regular expression matching, regular expression replacing. Commented Jun 23, 2012 at 11:09

1 Answer 1

1

A one liner:

$('input').keyup(function(){ $(this).val() === 'http://' && $(this).val(''); });

Or:

$('#validate').click(function(){ 
  var i = $('input');
  (/http:\/\//).test(i.val()) && i.val(i.val().replace('http://',''));
});
Sign up to request clarification or add additional context in comments.

4 Comments

Can you please explain the first one? Looks confusing for me
oh bro i want to do this without any press key
sry bro its better but i want http removed but the rest of the sentenc remains
You'll figure it out eventually. You can start here regular-expressions.info

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.