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 6388887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:20:08+00:00 2026-05-25T03:20:08+00:00

I am trying to modify following script to do this check: Check if input

  • 0

I am trying to modify following script to do this check:

Check if input VALUE and ALT are the same.

If yes: empty VALUE

If no: keep VALUE

This is the script I am working on: (the part that i commented out, is where i tryed to figure out how to make the changes myself).

    <script language="Javascript" type="text/javascript">
        //<![CDATA[
        jQuery.fn.placeholder = function(){
            return this.each(function(){
                var element = $(this)
                var insertedNow =element.after("<span class='placeholder-spanbox'>"+ element.attr('alt')+ "</span>").attr("alt","").next('.placeholder-spanbox');
                var leftOffset = (element.innerWidth() - element.width())/2+parseInt(element.css("border-left-width"));
                var topOffset = ((element.innerHeight() - element.height())/2)+parseInt(element.css("border-top-width"));
                var inputWidth = element.width();   
                var inputHeight = element.height(); 
                var placeholderPos = inputHeight + topOffset + leftOffset;

                insertedNow.css("padding-left",leftOffset+"px").css("padding-top",topOffset+"px").css("opacity",0.5).css("display","block").css("margin-top",-placeholderPos).css("cursor","text");
                var objCSS = {'-webkit-transition':'opacity 100ms ease-in','-moz-transition':'opacity 100ms ease-in','-o-transition':'opacity 100ms ease-in','-ms-transition':'opacity 100ms ease-in','transition':'opacity 100ms ease-in','font-size':element.css('font-size'),'font-family':element.css('font-family'),'color':'#000000','font-weight':element.css('font-weight'),'width':element.css('width'),'float':element.css('float')};
                insertedNow.css(objCSS);
                //insertedNow.offset(element.offset());
                element.bind("focus",updateSpanStatusFocus);
                element.bind("keydown",updateSpanStatusKeyDown);
                element.bind("keyup",updateSpanStatusKeyUp);
                element.bind("blur",updateSpanStatusBlur);
                insertedNow.bind("click",clickSpanBox);


                var inputVal = element.attr("value");
                var inputAlt = element.attr("alt");

                //$(this).attr("value",+inputVal);

                // if(inputVal == inputAlt){
                //  $(this).attr("value","123");
                // }    

                if(element.val()!==""){
                    insertedNow.css({'opacity':0});
                }
            });
            function clickSpanBox(event){
                event.preventDefault();
                var inputBox = $(this).prev();
                inputBox.focus();
            }
            function updateSpanStatusFocus(event){
                var $this= $(this);
                if($this.val()==""){
                    var spanBox = $this.next('.placeholder-spanbox');
                    spanBox.css("opacity","0.3");
                }
            }
            function updateSpanStatusKeyUp(event){
                var $this= $(this);
                if($this.val()==""){
                    var spanBox = $this.next('.placeholder-spanbox');
                    spanBox.css("opacity","0.3");
                }
            }
            function updateSpanStatusKeyDown(event){
                var $this = $(this);
                if($this.val()=="" && (event.keyCode>54 || event.keyCode == 32)){
                    var spanBox = $this.next('.placeholder-spanbox');
                    spanBox.css("opacity","0");
                }
            }
            function updateSpanStatusBlur(){
                var $this= $(this);
                $this.val(Trim($this.val()+''));
                if($this.val()==""){
                    var spanBox = $this.next('.placeholder-spanbox');
                    spanBox.css("opacity","0.5");
                    spanBox.css("color","#000000");
                }
            }
        }

        $(document).ready(function(){
            $('.spanOverlay').placeholder();
        });

        //]]>
    </script>

And here the html markup example:

<input type='text' name="userName" class='contactInput spanOverlay' alt='* Name' value='test'></input>

Thanks for your help!!

  • 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-05-25T03:20:09+00:00Added an answer on May 25, 2026 at 3:20 am

    Is this what you want?

    if (element.val() == element.attr('alt')) {
        element.val("");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to modify the following script to show/hide the Tip only when
I'm trying to modify my GreaseMonkey script from firing on window.onload to window.DOMContentLoaded, but
This is a simple toy script, but I'm having issues with it. I'm trying
In TFS 2008, I am trying to modify a build script (TFSBuild.proj). I get
I'm trying to modify the Connection header with the following code with no success
I have the following html that I am trying to modify: <div class=col1 width8><img
I'm trying to modify the following rewrite conditions so that only strings that begin
I'm trying to modify a ksh script to print out the line that contains
I'm trying to make a script in photoshop that will modify some layers and
I'm trying to modify the following query to find the rank of a specific

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.