0

I have a validation script, and I'm tying to check if the first name field is left blank. I originally just changed the background color of the field and that worked, but now I want to use jquery to fade in a highlight. This is the code so far.

var x = document.forms['getinfo']['fname'].value;
var validated = true;
if (x==null || x =="") { 
    //document.getElementById('trfname').style.background="#FF9999";
    document.getElementById('trfname').style.borderRadius = '7px';
    $("trfname").effect("highlight", {}, 3000);
    validated = false;
}

As you can see I commented out the old javascript code that worked and I'm trying to use the jquery highlight function. It's not working and I was wondering if anyone had some input. I've checked if Jquery loads properly and it does, so it's not that. I also included the jquery-ui library, to no avail.

2 Answers 2

4

You are looking for an element named trfname, not an id. Add the missing #.

$("#trfname").effect("highlight", {}, 3000);
Sign up to request clarification or add additional context in comments.

Comments

0
var x = $('form[name="getinfo"] input[name="fname"]').val();
var validated = true;
if (x.length < 1) { 
    $('#trfname').css('border-radius', '7px').effect("highlight", {}, 3000);
    validated = false;
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.