...

View Full Version : how to put a border around an input box



kevinkhan
12-26-2011, 02:31 PM
how do i put a red border around an input box with a class of .input1 if it goes into this loop??



if(firstName=='' || firstName.length < 3 || firstName=='First Name:' ){
error = 'Please enter your first name';
$j('#errormsg').html('<p class="errors">'+ error +'</p>');

return false;
}

jmrker
12-26-2011, 03:03 PM
Not really a JS problem.


<input type="text" style="border:3px dotted red" value="">

Change the CSS style to match your needs.

kevinkhan
12-26-2011, 03:07 PM
Not really a JS problem.


<input type="text" style="border:3px dotted red" value="">

Change the CSS style to match your needs.

yes but i only want it to change when it goes into the if statement.

jmrker
12-26-2011, 03:32 PM
Have not see the rest of your code, so this is just a snippit guess as to what you are trying to do.


<!DOC HTML>
<html>
<head>
<title> Untitled </title>
<style type="text/css">
.err { border:3px dotted red; }
.OK { border:1px solid black; }
</style>

<script type="text/javascript">
function checkInput() {
var sel = document.getElementById('firstName');
if ( (sel.value=="") || (sel.value.length <3) || (sel.value=='First Name:') ) {
sel.className = 'err'; alert('Entry error');
} else {
sel.className = 'OK';
}
}
</script>

</head>
<body>
<form onsubmit="return false">
<input id="firstName" type="text" class='OK' value="First Name:">
<button onclick="checkInput()">Check</button>
</form>
</body>
</html>

Additional logic could be used to clear input after entry errors!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum