|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Web Form Question...
Sorry if this belongs in a different category, I'm just not sure what I need here...
Someone has created a web form for online registration in (I believe) ASP.NET. What I want to do is create the standard mandatory requirement: "you didn't insert a proper phone"/ "you didn't enter a valid email address". Is this something I can just add to the HTML code, or does it require further .NET coding? Here's what I have thus far, which works great, but does not actually require any of the fields to be completed... <form method = "GET" action="/ASPNET/contactformresults.aspx" enctype ="text/plain" ID="Form1"> <input type=hidden name="Redirect" value="/submit/thanks.htm"> <table height="110" ID="Table1"> <tr> <td height="15">Name: </td> <td height="15"><input runat=server name="name" size="26" ID="Text1"></td> </tr> <tr> <td height="15">Phone: </td> <td height="15"><input name="phone" size="26" ID="Text4"></td> </tr> <tr> <td height="15">Email: </td> <td height="15"><input name="email" size="26" ID="Text5"></td> </tr> <tr> <td height="15" colspan=2 align=right> <input type = "submit" value="submit" ID="Submit1" NAME="Submit1"> </td> </tr> </table> </form> |
|
#2
|
||||
|
||||
|
If it is in ASP.NET, then you can just use the built-in .NET Required Field Validation control. Alternately, you could write client-side javascript to validate the form.
|
|
#3
|
|||
|
|||
|
Javascript assistance requested...
Alright, just the database portion is in ASP.NET. So I'll have to go w/ jscript for the required field functionality. Could anyone point me to sample code for such functionality to get me started? I'm on my own on this one and have only dabbled in jscript for 10 minutes (2 years ago)!
Thanks, John |
|
#4
|
||||
|
||||
|
Here's a simple example.
Code:
<script language="JavaScript">
function validateField(value, fieldName)
{
if(value == '')
alert(fieldName + " is required");
}
</script>
<form name="form1">
<table height="110" ID="Table1">
<tr>
<td height="15">Name: </td>
<td height="15"><input runat=server name="txtName" size="26" onBlur="javascript:validateField(this.value, 'Name')"></td>
</tr>
<tr>
<td height="15">Phone: </td>
<td height="15"><input name="txtPhone" size="26" onBlur="javascript:validateField(this.value, 'Phone')"></td>
</tr>
<tr>
<td height="15">Email: </td>
<td height="15"><input name="txtEmail" size="26" onBlur="javascript:validateField(this.value, 'Email')"></td>
</tr>
<tr>
<td height="15" colspan=2 align=right>
<input type = "submit" value="submit" ID="Submit1" NAME="Submit1">
</td>
</tr>
</table>
</form>
|
![]() |
| Viewing: ASP Free Forums > Programming > HTML, JavaScript And CSS Help > Web Form Question... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|