Highlight Textbox On Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies
Requiredfieldvalidator Change Textbox Border Color
of this site About Us Learn more about Stack Overflow the company Business javascript validation change textbox color Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask
How To Change Textbox Border Color Whenever Validation Fails Using Javascript
Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign highlight textbox on validation error jquery up How do I highlight a textbox border red when it is required? up vote 4 down vote favorite 6 What property do I use on the required field validator control to make the textbox red if there is a validation error? Here is my code: might have Meta Discuss the workings and policies of this jquery validate textbox border red site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community http://stackoverflow.com/questions/21237890/how-do-i-highlight-a-textbox-border-red-when-it-is-required of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up JS validation highlight input field red/green up vote 6 down vote favorite 2 I am creating a simple JS validation for my HTML form. The validation checks if the fields are empty and in some http://stackoverflow.com/questions/21127083/js-validation-highlight-input-field-red-green cases checks both, if they're empty and input !numbers. This check works well but what I am also trying to achieve is to highlight the field in red if JS detects invalid input. I have coded some JS to style the input field if the input is invalid but it is the highlight that does not work. JS snap function FormValidation(){ //First Name Validation var fn=document.getElementById('firstname').value; if(fn == ""){ alert('Please Enter First Name'); document.getElementById('firstname').style.borderColor = "red"; return false; }else{ document.getElementById('firstname').style.borderColor = "green"; } if (/^[0-9]+$/.test(document.getElementById("firstname").value)) { alert("First Name Contains Numbers!"); document.getElementById('firstname').style.borderColor = "red"; return false; }else{ document.getElementById('firstname').style.borderColor = "green"; } if(fn.length <=2){ alert('Your Name is To Short'); document.getElementById('firstname').style.borderColor = "red"; return false; }else{ document.getElementById('firstname').style.borderColor = "green"; } HTML snap
How To Make Textbox Border Red Using Jquery