so ändern Sie die Rahmenfarbe des Input-Feldes dynamisch in jquery mobile

Ich habe ein input-Feld, in dem will ich geben Validierung "ich bin", ändern Sie den Platzhalter text und seine Farbe, aber ich auch die Farbe ändern möchten, im Eingabefeld Grenze.
hier ist der code der html:

<input class="validate[required,custom[onlyLetterSp]] text-input" id="first_name" name="firstName" type="text" placeholder="First Name" maxlength="10" required>
    <input class="validate[required,custom[onlyLetterSp]] text-input" id="last_name" name="LastName" type="text" placeholder="Last Name" required>

hier ist der javascript code für die Validierung und ändern Sie Platzhalter Farbe:

var defaultColor = 'BBBBBB';
var styleContent = 'input:-moz-placeholder {color: #' + defaultColor + ';} input::-webkit-input-placeholder {color: #' + defaultColor + ';}';
var styleBlock = '<style id="placeholder-style">' + styleContent + '</style>';
var randomColor='ff0000';
    //generate new styles and append to the placeholder style block
    styleContent = 'input:-moz-placeholder {color: #' + randomColor + ';} input::-webkit-input-placeholder {color: #' + randomColor + ';}'
     var colorchng='<style id="placeholder-style">' + styleContent + '</style>';
     if(first_name=="" || first_name=="First Name"){

        $("#first_name").append(colorchng);
        $("#first_name").attr("placeholder","First Name can not be blank");
    } if(last_name=="" || last_name=="Last Name"){
         $("#last_name").append(colorchng);
        $("#last_name").attr("placeholder","Last Name can not be blank");
    }else{
            alert("Data Entered");
    }

InformationsquelleAutor Neerav Shah | 2013-07-27

Schreibe einen Kommentar