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 ?
-
1What do you have so far?yoda– yoda2012-06-23 10:56:13 +00:00Commented Jun 23, 2012 at 10:56
-
i want a solution for this can u help me more ?babak faghihian– babak faghihian2012-06-23 10:59:15 +00:00Commented 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 functionbabak faghihian– babak faghihian2012-06-23 11:00:38 +00:00Commented 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.elclanrs– elclanrs2012-06-23 11:04:22 +00:00Commented Jun 23, 2012 at 11:04
-
1javascript regular expression, regular expression matching, regular expression replacing.sabithpocker– sabithpocker2012-06-23 11:09:02 +00:00Commented Jun 23, 2012 at 11:09
|
Show 1 more comment
1 Answer
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://',''));
});
4 Comments
sabithpocker
Can you please explain the first one? Looks confusing for me
babak faghihian
oh bro i want to do this without any press key
babak faghihian
sry bro its better but i want http removed but the rest of the sentenc remains
elclanrs
You'll figure it out eventually. You can start here regular-expressions.info