I'm trying to write the javascript to check for empty fields and hightlight the field when it empty the javascript check is working but the style I'm not sure how to do that.
Nomvula
Why not use the RequiredFieldValidator control - is this an option? That way you don't have to actually do any of your own JavaScripting? (Remember - it's _all_ about productivity these days )
-----------------------------------------------
"The night sky over the planet Krikkit is the least interesting sight in the entire universe."
-Hitch Hiker's Guide To The Galaxy
Thanks guys
I've done the validations using javascript and it worked my problem is I need to include the style that will change the background of the textbox if there's an error, here's my script:
<script language="javascript">
<!--
function isformvalid()
{
//Load Vars from form
txtFirst_Name = document.frmValidate.txtFirst_Name.value;
//alert(txtFirst_Name);
txtSurname = document.frmValidate.txtSurname.value;
txtEmail = document.frmValidate.txtEmail.value;
txtPostal_Code = document.frmValidate.txtPostal_Code.value;
msgHeader = "The form contains the following errors:\n\n";
errMsg = "";
numErrors = 0;
//First Name
if(txtFirst_Name==""{
errMsg += "Your first name is required,\n";
document.frmValidate.txtFirst_Name.focus();
document.getElementById("firstNameError".className = "show";
I'm not sure if the <input type="text"> control or CSS allows for highlighting the background of a textbox...but you can certainly get around this by displaying an image or emphasized error message.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.