Ver Mensaje Individual
  #14 (permalink)  
Antiguo 24/05/2003, 12:10
DotNetDeveloper
 
Fecha de Ingreso: abril-2003
Mensajes: 606
Antigüedad: 21 años
Puntos: 2
Calma Webstudio, no quiero llegar a las ofensas quiero que esto sea un post que deje algo.

Por poner un ejemplo, ya que ahora estoy en mi casa y no en el trabajo

Ejemplo funcionando:
http://es.gotdotnet.com/quickstart/a...alidator2.aspx

Código:
<%@ Page ClientTarget=UpLevel %>

<html>
<head>


    <script language="C#" runat=server>

        void Page_Load() {
            if (!IsPostBack) {
                // Validate intially to force *s to appear before the first round-trip
                Validate();
            }
        }

        void ValidateBtn_Click(Object Sender, EventArgs E) {

           if (Page.IsValid == true) {
              lblOutput.Text = "Página válida";
           }
           else {
              lblOutput.Text = "Algunos campos requeridos están vacíos";
           }
        }

   </script>

</head>
<body>

<h3><font face="Verdana">Ejemplo RequiredFieldValidator de cliente</font></h3>
<p>


<form runat="server">

    <table bgcolor="#eeeeee" cellpadding=10>
    <tr valign="top">
      <td colspan=3>
        <asp:Label ID="lblOutput" Name="lblOutput" Text="Rellenar los campos requeridos a continuación" ForeColor="red" Font-Name="Verdana" Font-Size="10" runat=server /><br>
      </td>
    </tr>

    <tr>
      <td colspan=3>
      <font face=Verdana size=2><b>Información de la tarjeta de crédito</b></font>
      </td>
    </tr>
    <tr>
      <td align=right>
        <font face=Verdana size=2>Tipo de tarjeta:</font>
      </td>
      <td>
        <ASP:RadioButtonList id=RadioButtonList1 RepeatLayout="Flow" onclick="ClientOnChange();" runat=server>
            <asp:ListItem>MasterCard</asp:ListItem>
            <asp:ListItem>Visa</asp:ListItem>
        </ASP:RadioButtonList>
      </td>
      <td align=middle rowspan=1>
        <asp:RequiredFieldValidator id="RequiredFieldValidator1" runat="server"
            ControlToValidate="RadioButtonList1"
            ErrorMessage="*"
            Display="Static"
            InitialValue=""
            Width="100%">
        </asp:RequiredFieldValidator>
      </td>
    </tr>
    <tr>
      <td align=right>
        <font face=Verdana size=2>Número de tarjeta:</font>
      </td>
      <td>
        <ASP:TextBox id=TextBox1 onchange="ClientOnChange();" runat=server />
      </td>
      <td>
        <asp:RequiredFieldValidator id="RequiredFieldValidator2" runat="server"
            ControlToValidate="TextBox1"
            ErrorMessage="*"
            Display="Static"
            Width="100%">
        </asp:RequiredFieldValidator>

      </td>
    </tr>
    <tr>
      <td align=right>
        <font face=Verdana size=2>Fecha de caducidad:</font>
      </td>
      <td>
        <ASP:DropDownList id=DropDownList1 onchange="ClientOnChange();" runat=server>
            <asp:ListItem></asp:ListItem>
            <asp:ListItem >06/00</asp:ListItem>
            <asp:ListItem >07/00</asp:ListItem>
            <asp:ListItem >08/00</asp:ListItem>
            <asp:ListItem >09/00</asp:ListItem>
            <asp:ListItem >10/00</asp:ListItem>
            <asp:ListItem >11/00</asp:ListItem>
            <asp:ListItem >01/01</asp:ListItem>
            <asp:ListItem >02/01</asp:ListItem>
            <asp:ListItem >03/01</asp:ListItem>
            <asp:ListItem >04/01</asp:ListItem>
            <asp:ListItem >05/01</asp:ListItem>
            <asp:ListItem >06/01</asp:ListItem>
            <asp:ListItem >07/01</asp:ListItem>
            <asp:ListItem >08/01</asp:ListItem>
            <asp:ListItem >09/01</asp:ListItem>
            <asp:ListItem >10/01</asp:ListItem>
            <asp:ListItem >11/01</asp:ListItem>
            <asp:ListItem >12/01</asp:ListItem>
        </ASP:DropDownList>
      </td>
      <td>
        <asp:RequiredFieldValidator id="RequiredFieldValidator3" runat="server"
          ControlToValidate="DropDownList1"
          ErrorMessage="*"
          Display="Static"
          InitialValue=""
          Width="100%">
        </asp:RequiredFieldValidator>
      </td>
      <td>
    </tr>
    <tr>
      <td></td>
      <td>
        <ASP:Button id=Button1 text="Validar" OnClick="ValidateBtn_Click" runat="server" />
      </td>
      <td></td>
    </tr>
    </table>

</form>

<script language=javascript>
<!--
    function ClientOnChange() {
       if (typeof(Page_Validators) == "sin definir")
          return;
       document.all["lblOutput"].innerText = Page_IsValid ? "Página válida" : "Algunos campos requeridos están vacíos";
    }
// -->
</script>


</body>
</html>
Siento ponerles un ejemplo de un tutorial pero tengo hueva de hacerlo desde 0.

Ahora bien, ustedes me pueden indicar una función, control como lo quieran llamar para que el mismo PHP valide formularios como lo es:

Código:
<asp:RequiredFieldValidator id="RequiredFieldValidator3" runat="server"
          ControlToValidate="DropDownList1"
          ErrorMessage="*"
          Display="Static"
          InitialValue=""
          Width="100%">    </asp:RequiredFieldValidator>
Para ASP.Net y me pueden decir si PHP es orientado a eventos.
Ahi se los dejo, nos vemos luego