Loading ...
Sorry, an error occurred while loading the content.

Re: help me for the validation of Name field

Expand Messages
  • fishkill777
    The basic validation involves checking whether a field has not been left blank. You can refer to some examples at this link...
    Message 1 of 5 , May 7, 2005
    • 0 Attachment
      The basic validation involves checking whether a field has not been
      left blank. You can refer to some examples at this link...

      http://www.w3schools.com/js/js_examples_3.asp (see examples in Form
      Object)

      -fish

      --- In javascript_official@yahoogroups.com, B Tripathy
      <baunty1035@y...> wrote:
      >
      > I have to validate a field (Name )
      >
      > Please write to me the code for it. just the basic lines
      >
      >
      >
      > ---------------------------------
      > Do you Yahoo!?
      > Yahoo! Mail - Find what you need with new enhanced search. Learn
      more.
      >
      > [Non-text portions of this message have been removed]
    • njr
      function checkinput(input){ $name = input.testField.value; $check= $name.indexOf(
      Message 2 of 5 , May 9, 2005
      • 0 Attachment
        <html>
        <head>
        <script language="JavaScript" type="text/javascript">
        function checkinput(input){
        $name = input.testField.value;
        $check= $name.indexOf('<');
        $check2=$name.indexOf('>');
        if ($check != -1 || $check2 != -1) {
        alert("invalid character detected!");
        return false;}
        if(input.name.value == ""){
        alert("You forgot to enter something.");
        return false;
        }
        }</script>
        </head>
        <body>
        <form name="testForm" onSubmit="return (checkinput(this));">
        <input type="text" name="testField" size=6 value="">
        </form>

        </body>


        I like to check for greater/less than symbols to prevent posting html
        tags - in addition to validating if anything was entered.
        I hope this helps!!

        --- In javascript_official@yahoogroups.com, "fishkill777"
        <fishkill777@y...> wrote:
        > The basic validation involves checking whether a field has not been
        > left blank. You can refer to some examples at this link...
        >
        > http://www.w3schools.com/js/js_examples_3.asp (see examples in Form
        > Object)
        >
        > -fish
        >
        > --- In javascript_official@yahoogroups.com, B Tripathy
        > <baunty1035@y...> wrote:
        > >
        > > I have to validate a field (Name )
        > >
        > > Please write to me the code for it. just the basic lines
        > >
        > >
        > >
        > > ---------------------------------
        > > Do you Yahoo!?
        > > Yahoo! Mail - Find what you need with new enhanced search. Learn
        > more.
        > >
        > > [Non-text portions of this message have been removed]
      • njr
        here is another good tutorial on the subject: http://www.devshed.com/c/a/JavaScript/Form-Validation-with-JavaScript/
        Message 3 of 5 , May 9, 2005
        • 0 Attachment
        • komando maradona
          function validateform() { //regular expression, checks that name has at least two characters var nameRE = /^[- w s]{2,30}$/; var message = ; var newWindow;
          Message 4 of 5 , May 10, 2005
          • 0 Attachment
            function validateform() {

            //regular expression, checks that name has at least two characters
            var nameRE = /^[-\w\s]{2,30}$/;
            var message ="";
            var newWindow;
            var valid = 1;

            if (document.getElementById("myField").Name.value == "" || (!nameRE.test(document.getElementById("myField").Name.value)))
            {
            valid = 0
            message += "\n\tPlease enter a valid first name at least three characters long.\n<br />";
            }

            // Here we decide whether to submit the form.
            if (!valid) {
            newWindow = open("","","top=200,left=200,width=400,height=300");
            newWindow.document.open();
            newWindow.document.write("<html><head><title>Form Validation</title></head><body><p>message + "</p></body></html>");
            newWindow.document.close();
            return false;
            }
            return valid;
            }




            --

            Whatever you Wanadoo:
            http://www.wanadoo.co.uk/time/

            This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm
          Your message has been successfully submitted and would be delivered to recipients shortly.