Forums

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

Home Forums CSS Javacript URL validation

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #34946

    Hi mi currently have the following code that checks if there is the “http://” in front of it and if there is none it adds it

    $('.urlinput').keypress(function(e) {
    if (e.keyCode == 13) {

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

    if (ini !== 'http') {
    cur_val = value
    value.val('http://' + cur_val + '/');
    }

    }
    });

    My question is how do i integrate a validation system?

    #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" ***
    }
    });
Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘CSS’ is closed to new topics and replies.