Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Javacript URL validation Re: Javacript URL validation

#89812
Mottie
Member

Try this:

$('.urlinput').keypress(function(e) {
// use e.which here, it's been normalized across browsers by jQuery
if (e.which === 13) {

var value = $(this).val();
var ini = $(this).val().substring(0, 4);

if (ini !== 'http') {
value = 'http://' + value + '/';
$(this).val(value);
}
// *** ADD your URL validation here; check "value" ***
}
});