Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7778163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:19:40+00:00 2026-06-01T18:19:40+00:00

I have two input text fields. One is for entering the title of the

  • 0

I have two input text fields. One is for entering the title of the article and one is for the permalink of the article. What I’m wanting to do is have the permalink field disabled until text is inserted into the title field and when the user takes focus out of the title field then it runs a custom regex to replace spaces with hyphens and lowercases any uppercase letters.

<input type="text" id="title" name"title" />
<input type="text" id="permalink" name="permalink" />
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T18:19:42+00:00Added an answer on June 1, 2026 at 6:19 pm

    It’s real easy with jQuery…

    var permalinkInput = $('#permalink');
    
    $('#title').change(function() {
        permalinkInput.prop('disabled', !$(this).val());
    }).change().blur(function() {
        $(this).val(function(i, value) {
            return value.replace(/\s+/g, '-').toLowerCase();
        });
    });​
    

    jsFiddle.

    If you don’t have jQuery but only need to support standards-compliant modern browsers, it’d be…

    var permalinkInput = document.querySelector('#permalink'),
        titleInput = document.querySelector('#title');
    
    permalinkInput.disabled = true;
    
    titleInput.addEventListener('change', function() {
        permalinkInput.disabled = !titleInput.value;
    }, false);
    
    titleInput.addEventListener('blur', function() {
        titleInput.value = titleInput.value.replace(/\s+/g, '-').toLowerCase();
    });​
    

    jsFiddle.

    If you didn’t have jQuery and had to support our old IE friends, it’d look like…

    var permalinkInput = document.getElementById('permalink'),
        titleInput = document.getElementById('title');
    
    var addEvent = function(element, type, callback) {
        if (element.addEventListener) {
            element.addEventListener(type, callback, false);
        } else if (element.attachEvent) {
            element.attachEvent('on' + type, callback);
        } else {
            element['on' + type] = callback;
        }
    }
    
    permalinkInput.disabled = true;
    
    addEvent(titleInput, 'change', function() {
        permalinkInput.disabled = !titleInput.value;
    });
    
    addEvent(titleInput, 'blur', function() {
        titleInput.value = titleInput.value.replace(/\s+/g, '-').toLowerCase();
    });​
    

    jsFiddle.

    Note that the old fallback for event registration is to assign the on* property. This will overwrite any previous property assigned there.

    If you really wanted to register multiple events for these ancient browsers, you’d modify the property assignment to use a custom handler which registered and then triggered multiple events when required.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form with two input fields, one text and one send button.
I have an HTML5 Canvas on my page along with two text input fields.
I have two inputs (text fields) required by JQuery Plug-in : <input type=text name=first_name
I have an html form with two input fields, in first one user puts
I have two text input fields like so: <input type=text id=test1.../> <input type=text id=test2.../>
I have two fields <form action=insert.php method=post> Firstname: <input type=text name=firstname /> Lastname: <input
I have a form in CakePHP that has two live-search text input. Each one
I have two html text input fields and two buttons. The first button saves
I have two text fields which whatever user enters in first text field, it
On the form, I have one select and two input fields. These elements are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.