Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

required fields an asterisks?

Status
Not open for further replies.

Whitebat

Technical User
Jun 19, 2001
47
DE
Hi that may be a dumb question but hopefully i will get an answer so i dont stay dumb lol.
i have several screens with required fields. But i cant find the command in the jsp code. so what is the command to do a required field with an * at the beginning? I know that the required thing might come out of my database but than the asterisk i have in front of my textfield should stand in the label but it doesnt. so i am confused. i couldnt find any significant difference between a required and nonrequired field. i know this is a confused explanation but maybe somebody is able to actually clue into what i mean.
Thanks for ur help

Thanks Whitebat
 
For me, to do an '*' is just using HTML to write out the '*'. Then, since it is a required field, & all these fields will need to be in a form, I use JavaScript functions to validate whether the fields are left empty or not.

For eg. in my HTML Form,

<FORM Name=&quot;myform&quot; method = &quot;Post&quot; onSubmit=&quot;return checkform()&quot;>
* Name : <INPUT TYPE=&quot;Text&quot; Name=&quot;Name&quot;>
<BR>
<INPUT TYPE=&quot;Submit&quot; Value=&quot;Submit&quot; />
</FORM>

Then in my JavaScript, I will have something like this,

function checkform() {

//only do the check for required field.
//if required field has no inputs, it pops out
//an alert box.
if (document.myform.Name.value = '') {
alert('Name is a required field!');
return false;
}

//if javascript can come here, it means that required
//field has inputs and will continue your form submission
return true;
}

Hope my explanation is what you are looking for...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top