Javascript SSN validator...

Hi everyone,
I am looking for a javascript which validates the format of SSN
If i have to enter SSN in a text field
1.It has to accept only numbers (no characters)
2.It has to add the string '-' automatically when the users entering the SSN
3.It has to validate whether users entered correct no of digits (9 digits)
Does anyone encountered or implemented such kind of javascript validations for a SSN no?
Please let me know if this is possible to do
Thank you
phani

Hi everyone,
I am looking for a javascript which validates the
format of SSN
f i have to enter SSN in a text field
1.It has to accept only numbers (no characters)
2.It has to add the string '-' automatically when
the users entering the SSN
3.It has to validate whether users entered correct no
of digits (9 digits)
Does anyone encountered or implemented such kind of
javascript validations for a SSN no?
Please let me know if this is possible to do
Thank you
phaniUsing google the following link(s) comes up:
http://javascript.internet.com/forms/val-ssn.html
http://www.yaldex.com/FSForms/ValidationSocialSecurityNumber.htm
http://blog.techsaints.com/2007/06/03/javascript-social-security-number-validation/
Thank you,
Tony Miller
Webster, TX

Similar Messages

  • SSN Validation Help

    I am creating a form that is to validate if the user has entered a valid SSN. I selected the correct validation pattern and checked "Error" to show the error message, but I would like to immediately reset the focus to the SSN field if it is invalid. I understand logically how to do this but I can't figure out the actual script for it.
    Taxpayer.#subform[0].Section1.TaxpayerSSN.fldTaxpayerSSN1::validate - (JavaScript, client)
    if (!!!HERE IS WHAT I CANT FIGURE OUT!!!)
    xfa.host.setFocus(this)
    Any help?

    Well, nevermind. I guess I figured out a solution. Just for reference, here is what I came up with. Most notable is the fact that I moved to the "Exit" event.
    Taxpayer.#subform[0].Section1.TaxpayerSSN.fldTaxpayerSSN1::exit - (JavaScript, client)
    var re = /^([0-6]\d{2}|7[0-6]\d|77[0-2])([ \-]?)(\d{2})\2(\d{4})$/;
    if (!re.test(this.rawValue) && this.rawValue != null)
    xfa.host.messageBox("Please enter a valid Social Security Number");
    xfa.host.setFocus(this);
    else
    var temp = value;
    if (value.indexOf("-") != -1)
    temp = (value.split("-")).join("");
    if (value.indexOf(" ") != -1)
    temp = (value.split(" ")).join("");
    if (temp.substring(0, 3) == "000")
    xfa.host.messageBox("Please enter a valid Social Security Number");
    xfa.host.setFocus(this);
    if (temp.substring(3, 5) == "00")
    xfa.host.messageBox("Please enter a valid Social Security Number");
    xfa.host.setFocus(this);
    if (temp.substring(5, 9) == "0000")
    xfa.host.messageBox("Please enter a valid Social Security Number");
    xfa.host.setFocus(this);
    I borrowed and modified this code from this location:
    http://www.breakingpar.com/bkp/home.nsf/0/87256B280015193F87256F6A0072B54C

  • How do i call servlet from javascript after validation the javascript

    Hi ,
    Can anyone tell me how to call a servlet after the javascript is being validated. Here is my code to validate javascript i need to call a servlet inorder to save the data into the same form. I tried calling through the action method in the form but its directly taking me to the servlet but not validating the form. Is there any way that i can validate the form first then call the servlet.
    Thanks in advance.
    <html>
    <head>
    <title>Online Blog</title>
    <script language ="javascript" type ="text/javascript">
    function myfunction()
    var mesg = "";
    var dmesg = "";
    var dnumber = 0;
    var number = 0
    var Blogstr = document.onlineblog.BlogName;
    var Fnamestr = document.onlineblog.FirstName;
    var Lnamestr = document.onlineblog.LastName;
    var Datestr = document.onlineblog.Dateformat;
    var Imagestr = document.onlineblog.uploadimage;
    var Imageval = Imagestr.value;
    var flength = parseInt(Imageval.length) - 3;
    var fext = Imageval.substring(flength,flength + 3);
    var Dateval = Datestr.value;
    var Dformat = /^\d{2}\/\d{2}\/\d{4}/; //checks the date format.
    //splits date into mm, dd , yyyy format.
    var m = Dateval.split("/")[0];
    var d = Dateval.split("/")[1];
    var y = Dateval.split("/")[2];
    //Get today's date (removes time).
    var today = new Date();
    var dd = today.getDate();
    var mm = today.getMonth()+1;
    var yyyy = today.getFullYear();
    //checks if month and date are displayed in mm, dd format and if not sets to mm,dd.
    if (mm <10)
    mm = '0'+mm;
    if (dd <10)
    dd = '0'+dd;
    //checks if name of the blog is empty
    if(Blogstr.value == "")
    number = number+1;
    mesg += "\n" + number + "Name of the blog";
    //checks if value of Frist Name is empty;
    if(Fnamestr.value == "")
    number = number+1;
    mesg += "\n" + number + "First Name";
    //checks if value of Last Name is empty;
    if(Lnamestr.value == "")
    number = number+1;
    mesg += "\n" + number + "Last Name";
    //checks if value of date is empty;
    if(Datestr.value == "")
    number = number+1;
    mesg += "\n" + number + "Date of mm/dd/yyyy format";
    //checks if value of image field is empty;
    if(Imagestr.value == "")
    number = number+1;
    mesg += "\n" + number + "select an image";
    //displays all the error messages.
    if (number > 0)
    alert ("Please enter the following" + mesg);
    return false;
    //checks if entered date format is mm/dd/yyyy
    if(!Dformat.test(Dateval))
    dnumber = dnumber +1;
    dmesg += "\n" + dnumber + "please enter a valid date(mm/dd/yyyy)";
    //checks if date is greater than 12 and is 2 digits.
    if ((m>12 && m<100) || (m> = 100 && m<1000) || (m==0))
    dnumber = dnumber+1;
    dmesg += "\n" + dnumber + "Enter valid month(mm)";
    //checks if month has 31 or 30 days and is in dd format.
    if (((d>30) && (d<100) && (m == 04 || m == 06 || m == 9 || m == 11)) || ((m == 01 || m == 03 || m == 05 || m == 07 || m == 08 || m == 10 || m==12) && (d >31) && (d<100)) || d == 0)
    dnumber = dnumber+1;
    dmesg += "\n" + dnumber + "Enter valid date(dd)";
    //checks if month has 28 or 29 days and wheather is a leap year or not.
    if((m == 02 && d>29 && y%4 == 0) || (m == 02 && d>28 && y%4 != 0))
    dnumber = dnumber+1;
    dmesg += "\n" + dnumber + "Enter valid date(dd)";
    //checks if entered date is prior to the current date.
    if((m == mm && d == dd && y == yyyy) || (y > yyyy)|| (d>=dd && m>=mm && m<=12 && y==yyyy) || (d<=dd && m>mm && y == yyyy && m<=12))
    dnumber = dnumber + 1;
    dmesg += "\n" + dnumber + "Please enter a date prior to the current date";
    if (y == 0 || y < 1000 || y>9999) //checks if year is zero and is a 4 digit number.
    dnumber = dnumber + 1;
    dmesg += "\n" + dnumber + "Enter a valid year(yyyy)";
    //checks if image format is jpg or gif.
    if(fext != "jpg" && fext != "gif")
    dnumber = dnumber + 1
    dmesg += "\n" + dnumber + "You can only upload gif or jpg images.";
    if(dnumber>0)
    alert("please check the followin error messages"+dmesg);
    return false;
    </script>
    <style type="text/css">
    .style1 {color: #FF0000}
    body {
         background-color: #FFCCFF;
    h2 {
         color: #CC3399;
    h1 {
         color: cc3399;
    .style2 {
         font-family: Arial, Helvetica, sans-serif;
         font-weight: bold;
    .style5 {color: #000000; font-family: "Times New Roman", Times, serif;}
    </style>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><body>
    <h1 align="center">Webloggers space</h1>
    <p align="center">Home
    <p>
    <h4> Please enter the following details to register.</h4>
    <p> <b>Note:</b> All fields marked with <span class="style1">*</span>(astrick)
    are compulsory.</p>
    <form action="servlet/BlogServlet" name="onlineblog" onsubmit = "return myfunction()" method="post">
    <table width="60%" border="0" cellspacing="5" cellpadding="2">
    <tr>
    <td><span class="style1">*</span>Name of the Blog</td>
    <td><input type="text" name="BlogName"/></td>
    </tr>
    <tr>
    <td><span class="style1">*</span>First Name</td>
    <td><input type="text" name="FirstName"/></td>
    </tr>
    <tr>
    <td><span class="style1">*</span>Last Name</td>
    <td><input type="text" name="LastName"/></td>
    </tr>
    <tr>
    <td><span class="style1">*</span>Date(mm/dd/yyyy)</td>
    <td><input type="text" name="Dateformat"/></td>
    </tr>
    <tr>
    <td>Category</td>
    <td><select name="catagory" size="1">
    <option></option>
    <option>Business</option>
    <option>Education</option>
    <option>Entertainment</option>
    <option>Food</option>
    <option>Hobbies</option>
    <option>Personal</option>
    <option>Politics</option>
    <option>Sports</option>
    </select></td>
    </tr>
    <tr>
    <td>Enter your text here:</td>
    <td><textarea name="textarea" cols="45" rows="5"></textarea></td>
    </tr>
    <tr>
    <td><span class="style1">*</span>Upload Image <span class="style5">(.jpg
              or .gif)</span></td>
    <td><input type="file" name="uploadimage" /></td>
    </tr>
    <tr>
    <td></td>
    <td><input type="submit" value="save">
    <input type="reset" name="reset" value="Reset" /></td>
    </tr>
    </table>
    </form>
    </body>
    </html>

    Your javascript code contains a syntax error. That's why the function isn't being called. Take a look at this line in your code.
    if ((m>12 && m<100) || (m> = 100 && m<1000) || (m==0))Notice the space between > and =. Remove that space.
    m >= 100

  • Using Javascript form validation in WordPress - Firefox issues

    I have been struggling for a while to get javascript to validate a WordPress based HTML form which uses radio buttons. I finally came up with a solution with was a bit long-winded but worked - at least in IE and Chrome - however, it doesn't work in Firefox (which suggests my code is a bit sloppy). I think my radio button reference is the issue. Can anyone help with what I have done wrong - apart from use an inefficient approach for validation :-)?
    A simplified version of my form:
    <script>
    function validateForm()
    var aa=document.forms["personalise"]["motivation"]["1a"];
    var ab=document.forms["personalise"]["motivation"]["1b"];
    var ac=document.forms["personalise"]["motivation"]["1c"];
    var ad=document.forms["personalise"]["motivation"]["1d"];
    var ae=document.forms["personalise"]["motivation"]["1e"];
    if (!(aa.checked == true || ab.checked == true || ac.checked == true || ad.checked == true || ae.checked == true))
    alert("Question 1 must be completed");
    return false;
    </script>
    <form name="personalise" action="insertdatatest.php" onsubmit="return validateForm()" method="post">
    1. Are you seriously planning to quit </b>:&nbsp;&nbsp;
    <input id="1a" type="Radio" title="" name="motivation" value="1" /> Within the next 2 weeks
    <input id="1b" type="Radio" title="" name="motivation" value="2" /> Within the next 30 days
    <input id="1c" type="Radio" title="" name="motivation" value="3" /> Within the next 3 months
    <input id="1d" type="Radio" title="" name="motivation" value="4" /> No, I am not currently planning to quit
    <input id="1e" type="Radio" title="" name="motivation" value="5" /> I have already quit
    <input type="submit" value = "Submit">
    </form>
    For My Website : http://www.schoolanduniversity.com

    Thanks for your support,
    This will partly solve the issue I think. Now, the validation is indeed only done for the first form. But I need to save data twice when entering data in the second grid. When checking the error console in mozilla I see following error:
    Error: grid[r] is undefined
    Which is reffering to:
              if ((grid[r] [1] != missing) ||(grid[r][2] != missing) || (grid[r][3] != missing))
    When I save again, the data will be saved without this error.
    Is there a way to exclude the second grid in the if Statement?
    Regards,
    Erik

  • Javascript generated validation error message not rendering properly.

    Hi guys. I am a web developer looking for some help with a Safari issue.
    I have a web form with client side validation. The page is built in asp.net and uses a validation summary to display the error messages in an unordered list. The validation is not the standard asp.net version, but a version they came up with at the company I work at.
    The validation produces some javascript in the page, which appears just before the closing </form> tag, which I understand can cause issues in Safari? However I cannot change the place it appears on the page because its part of a sort of CMS template.
    The validation text appears fine in other browsers, but in Safari it produces a white space. However if you highlight over the space, the text is revealed, and then stays on the page. Also if you scroll the page so that the space disappears off the top of the page, and then scroll back up again, the text is visible. Also if you click the submit button again the text is revealed.
    I have also found that if you use Safari in the Transparent Window mode, it all works fine.
    If anybody out there has any ideas what could be causeing the problem, I would be extremely grateful.
    Mac Mini Mac OS X (10.4.9) Safari 2.0.4

    Hi,
    no, there doesn't exist a client side JavaScript API for this. The message element is only rendered if there is a component error detected in the lifecycle. This means there is nothing you can hook into (e.g. using document.getElementById())
    Frank

  • Invoke javascript on validation error?

    Is there any way to invoke some javascript when I get a form validation error?

    I'm having problems with dynamic menus. I was getting that "value is not valid" error because my menus don't identically match the arraylist I initially provide them with in the backing bean. So I decided to just get around it with javascript.
    Anyway I think I have found a solution using this as a guide:
    http://balusc.blogspot.com/2007/12/set-focus-in-jsf.html

  • Mixing javascript & php validation

    I have been wrestling with the idea of processing and
    validating a page (form) within a single script and I'm still
    struggling with it. The source of my problem lies in the code
    Dreamweaver creates if you use the 'validate on Submit' behaviour.
    The javascript will do some basic validation via a function
    called MM_validateForm and return the result via
    'document.MM_returnValue'.
    This function is associated with the 'submit' button
    (onclick) so I can see how we validate, display errors, and check
    to see when we come back through the routine, if we've been here
    before (if (!$_POST['submit']) etc) but I can't see:
    i) What is re-displaying the calling routine in the event of
    an error - i.e. why is the page looping around when an error is
    found? I guess something in the 'onclick' is somehow interpreting
    the validity of the page and redirecting back around when there are
    problems but I can't what is driving this.
    ii) How I can expand the javascript routine with my own php
    code (I'm guessing I can't just add in php code to the function
    that Dreamweaver has written) to say, verify logon details against
    the db. If we go back around I can add in some extra code that will
    be executed on submit but if I get an error in my code, how do I
    convey that to the 'onclick' to take me back around again - the
    javascript function is in there already ... D'oh!
    Are you with me? ...... is there anybody there ....
    Thanks.
    P.

    If the form fails client-side validation, it never submits.
    When it
    submits, it will submit to a destination -
    <form action="destination"...
    That destination can be the form page itself, or it can be a
    form processing
    script on another page. That's where the server side
    validation kicks in.
    For example, if the form submits to itself, you put some
    scripting in the
    head of that page that tests to see if the form has been
    submitted, e.g., in
    PHP that would be -
    if(isset($_POST)) {
    server validation goes here
    If the form is submitting to another page, then obviously,
    you don't have to
    do this check.
    Make sense?
    One good reason why you'd want the form to submit to itself,
    would be If it
    fails the server scripted validation, then you would just let
    the form
    re-draw, but populate the fields with the data contained in
    the $_POST
    array, so that the user could make corrections more easily.
    Of course, you
    can set a variable describing the error(s) this way, and
    display them on the
    page as well.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    ==================
    "patricktr" <[email protected]> wrote in
    message
    news:[email protected]...
    > Hi Murray,
    >
    > I've been playing around with this to try and make sense
    of it so maybe I
    > took
    > it off the 'onsubmit' and put it on the 'onclick' - the
    point is how when
    > you've told it to validate at client level with the
    javascript do you then
    > tell
    > it to validate at the server level?
    >
    > I'm obviously not making myself clear or it's so
    blindingly obvious you
    > can't
    > understand what my problem is but I'll try again...
    >
    > Somehow or other when the javascript finishes the system
    knows there are
    > problems and display a pop-up and forces us back around
    the form loop
    > again.
    >
    > I can add in extra php code (if $_POST(SUBMIT...) that
    will do more
    > rigourous
    > validation at the server level (db checks etc) but how
    can I get it to
    > loop
    > back around and re-present itself? If I use 'header
    )location ... ' I
    > can't
    > seem to find a place where it happy to be re-directed -
    there is header
    > info
    > in a non-editable place brought on from a template (I
    didn't say that
    > befpore I
    > must admit) ....
    >
    > I'm sure this should be easy but .....
    >
    > P.
    >
    >
    >

  • PA0002-PERID (Personnel ID Number) eg.SSN Validation

    Hi folks
    I have a requirement to validate the field PA0002-PERID in my custom Module Pool Program.
    It should validate like the standard infotype program.
    I got the standard validation subroutine, which validates when the field is SSN for US.
    But for other countries I did not find any solution. Any suggestions?
    Regards.
    vim.

    >
    d sappanese wrote:
    > Thanks Rob
    >
    > Actually I ws specifically looking for Netherlands and UK
    Please check the FM 'TAX_NUMBER_CHECK', I believe this can be used for both NL and U.S and for GB you can check the subroutine 'GB_NINUM_Validation' in the include program MP00024G.
    -Rajesh.

  • External javascript for validation

    i have created a registeration form. and need to do validation for the form. but the problem now is that i need to create a external javascipt for valiation. and this scipt must be able to reuse on other form as well.
    can anyone please help me on that? teach me how to create one?

    To create an external JavaScript simply write the JavaScript in a text file and save the file with a .js extension.
    In the HTML reference the file with
    <Script Language="JavaScript" src="myFile.js"></Script>
    where "myFile.js" is the relative path and file name of your .js file.
    To reuse the same validation .js file in different pages you'll either have to :
    1: Pass the form elements being validated in as parameters to functions
    2: Make sure that the HTML form and all of the form elements have the same
    Here is a good link to working with JavaScript:
    http://developer.netscape.com/docs/manuals/js/client/jsguide/index.htm
    name or are in the same order in the DOM.

  • Urgent!! Process not invked after using javascript validation

    hi,
    I have created a javascript form validation and finally (if its passes the validation) I am setting the :REQUEST as doSubmit('GO');
    I am calling a conditional process with condition as request = expression1
    with expression 1 as GO.
    The javascript is as follows
    function message_name_not_null(){
    if(document.getElementById('P14_MESSAGE_NAME').value.length==0)
    alert("Message Name is Mandatory!!");
    return;
    else if(document.getElementById('P14_MESSAGE_TEXT').value.length==0)
    alert("Message Text is Mandatory!!");
    return;
    else
    doSubmit('GO');
    My problem is my process is not getting called in button click(I have called the javascript from this button as javascript:message_name_not_null(); in Optional URL Redirect section)
    I have specified the :REQUEST value in the branches also.
    Any sort of help please..
    Thanks in Advance
    Kaushik

    Hi Kaushik,
    this thread should help you:
    Validation with javascript
    greetings,
    Jochen

  • Pre-validation using JavaScript cannot work in JSF?

    Sometimes we need to do pre-validation using JavaScript in some senarios that data need be entered and validated at client site before it reaches to Web Application Server. Remind that JSF is a server validation. Creator seems not to allow Developers to do pre-validation using JavaScript for any editable input fields in form. I will illustrate an example and hope anyone can help me to solve it out.
    Assume that if we write the a new web page that allows User enters Name and Phone. The pre-validation function called test() is written in JavaScript for validating field Phone. For simplicity, the below HTML/JavaScript without nested in table is a simple one for HTML form.
    <html>
    <body>
    <script language="JavaScript">
    function test(){
         if (form1.phone.value == "")
              alert("Please enter phone number in digits.");
              return false;
    </script>
    <form name=form1>
    <input id="phone" type="text" size=20><Br>
    <input id="name" type="text" size=20><Br>
    <input type="submit" id="submit" onclick="test()" value="Submit">
    </form>
    </body>
    </html>
    Now, we consider using Java Studio Creator to generate the same form as describing above. The script is shown below:
    <?xml version="1.0"?>
    <jsp:root version="1.2" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page">
    <jsp:directive.page contentType="text/html;charset=UTF-8"/>
    <f:view>
    <html>
    <head>
    <title>testForm Title</title>
    </head>
    <body rave-layout="grid">
    <h:form binding="#{testForm.form1}" id="form1">
    <h:inputText binding="#{testForm.textField1}" id="phone" style="position: absolute; left: 192px; top: 96px; width: 168px; height: 23px"/>
    <h:inputText binding="#{testForm.textField2}" id="name" style="position: absolute; left: 192px; top: 144px; width: 168px; height: 23px"/>
    <h:commandButton binding="#{testForm.button1}" id="submit" style="position: absolute; left: 192px; top: 216px" value="Submit"/>
    </h:form>
    </body>
    </html>
    </f:view>
    </jsp:root>
    After running Script that Creator created, the HTML is generated and reduced (for simplicity) as follows:
    <f:view>
    <html>
    <body rave-layout="grid">
    <form action="/rave/rave" id="form1" method="post">
    <input id="form1:Phone" type="text"></input>
    <input id="form1:name" type="text"></input>
    <input id="form1:button1" value="Submit" onClick="test()"></input>
    </body>
    </html>
    </f:view>
    Take a look carefully at <input> elements. We see the syntax for naming for each "input" element that there is a semi colon added between form1 and phone or form1 and name. This syntax is generated from built-in JSF components. Hence, I rewrite the test() JavaScript function to match with the naming that Creator generated as follows:
    <script language="JavaScript">
    function test(){
         if (form1.form1:Phone.value == "")
              alert("Please enter phone number in digits.");
              return false;
    </script>
    Clearly, this JavaScript cannot be worked because of a semi column that Creator has named it.
    I have tried to work arround for this but cannot find a solution except changing the name such as: from <input id="form1:phone" ...> to <input id="form1_phone" ..>. But I could not change or modify the scripts because it is generated from JSF components when running it under browser.
    I guess to solve this problem, the naming for elements in form should be reconsidered in the next release of Java Studio Creator.

    Hi Marie,
    I currently sucess in client pre-validation using JSF. I found a way to do it.
    Please take a look of how javascript has been added in the following scripts:
    <?xml version="1.0" encoding="UTF-8"?>
    <jsp:root version="1.2" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page">
    <jsp:directive.page contentType="text/html;charset=UTF-8"/>
    <f:view>
    <html lang="en-US" xml:lang="en-US">
    <head>
    <meta content="no-cache" http-equiv="Cache-Control"/>
    <meta content="no-cache" http-equiv="Pragma"/>
    <title>login Title</title>
    </head>
    <body style="-rave-layout: grid">
    <h:form binding="#{login.form1}" id="form1">
    <h:outputLabel binding="#{login.componentLabel1}" for="componentLabel1" id="componentLabel1" style="position: absolute; left: 216px; top: 72px">
    <h:outputText binding="#{login.componentLabel1Text}" id="componentLabel1Text" value="Application System Name"/>
    </h:outputLabel>
    <h:panelGrid binding="#{login.gridPanel1}" columns="3" id="gridPanel1" style="position: absolute; left: 72px; top: 168px; width: 504px; height: 100px">
    <h:outputLabel binding="#{login.componentLabel2}" for="componentLabel2" id="componentLabel2">
    <h:outputText binding="#{login.componentLabel2Text}" id="componentLabel2Text" value="User Name: "/>
    </h:outputLabel>
    <h:inputText binding="#{login.textField1}" id="textField1" onclick="" style="width: 149px; height: 22px"/>
    <h:outputText binding="#{login.outputText1}" id="outputText1"/>
    <h:outputLabel binding="#{login.componentLabel3}" for="componentLabel3" id="componentLabel3">
    <h:outputText binding="#{login.componentLabel3Text}" id="componentLabel3Text" value="Password: "/>
    </h:outputLabel>
    <h:inputSecret binding="#{login.textField2}" id="textField2" style="width: 147px; height: 22px"/>
    <h:outputText binding="#{login.outputText2}" id="outputText2"/>
    <h:outputLabel binding="#{login.componentLabel4}" for="componentLabel4" id="componentLabel4">
    <h:outputText binding="#{login.componentLabel4Text}" id="componentLabel4Text"/>
    </h:outputLabel>
    <h:commandButton action="#{login.ok_action}" binding="#{login.button1}" id="button1" onclick="return checkUserIdentity(this.form)"
    style="width: 90px; height: 25px" value="OK"/>
    <h:outputLabel binding="#{login.componentLabel5}" for="componentLabel5" id="componentLabel5">
    <h:outputText binding="#{login.componentLabel5Text}" id="componentLabel5Text"/>
    </h:outputLabel>
    </h:panelGrid>
    </h:form>
    </body>
    <script type="text/javascript">
    function checkUserIdentity(form){
    var userName = form["form1:textField1"].value;
    var userPassword = form["form1:textField2"].value;
    if (userName == "") {
    alert("Please enter User Name.");
    form["form1:textField1"].focus();
    return false;
    if (userPassword == "" ){
    alert("Please enter password.");
    form["form1:textField2"].focus();
    return false;
    form.submit();
    return true;
    </script>
    </html>
    </f:view>
    </jsp:root>
    The key for getting data value from Form based on Javascripts is var userName = form["form1:textField1"].value;
    Thanks,
    VTT_

  • Validating forms in jsp using javaScript

    Hi all i'm trying to validate this form with javeScript. i was testing it with just the <input type=text name= file> first. it works but after the alert message it still posts to writeXML......
    i tried putting the fuction valid() after the <form> tag but it still posts it to writeXML.jsp.......can anyone help me please........What i want to do is make sure that something is typed in all the forms befor posting to writeXML..Thanx
    <html>
    <head> <title>Create MultipleChoice Questions</title> </head>
    <script language="JavaScript">
    function valid(form) {
         if(form.file.value == "")
         alert("Please enter the file name")
    </script>
    <body bgcolor="#cccccc">
    <% int count = 0;
    String number = request.getParameter("nOfq");
    int qNumber = Integer.parseInt(number); %>
    <form action="writeXML.jsp" method="POST">
    <center>
         <table bgcolor="silver" border="1" width="75%">
         <tr align="center"><td><b>Type in the Name of your Questionnaire here eg. BlackHistory.      Dont leave any spaces between letters</b><br>
         <textarea name="file" rows="1" cols="25"></textarea><br>
         </td></tr>
    <% for(int i=1;i<qNumber+1; i++) { %>
    <%count++;%>
         <tr align="center" bgcolor="#336699"><td><b>QUESTION <%= count %>: </b><br>
         </td></tr>
         <tr align="center"><td><b>ENTER QUESTION:</b><br>
         <textarea name=<%="questionText"+i%> rows="5" cols="65"></textarea><br>
         </td></tr>
         <tr align="center"><td><b>CHOICE 1:</b><br>
         <textarea name=<%="choice_1"+i%> rows="2" cols="50"></textarea><br>
         </td></tr>
         <tr align="center"><td><b>CHOICE 2:</b><br>
         <textarea name=<%="choice_2"+i%> rows="2" cols="50"></textarea><br>
         </td></tr>
         <tr align="center"><td><b>CHOICE 3:</b><br>
         <textarea name=<%="choice_3"+i%> rows="2" cols="50"></textarea><br>
         </td></tr>
         <tr align="center"><td><b>CHOICE 4:</b><br>
         <textarea name=<%="choice_4"+i%> rows="2" cols="50"></textarea><br><br><br>
         </td></tr>
         <tr align="center" bgcolor="#679995"><td><b>CORRECT ANSWER:</b><br>
         <textarea name=<%="cAnswer"+i%> rows="2" cols="50"></textarea><br><br><br>
         </td></tr>
    <% } %>
    <tr>
    <td align="center"><input type="submit" name="next" value="NEXTT" onClick="valid(this.form)">
    <td align="center"><input type="hidden" name="qCount" value="<%=count+1%>">
    </td></tr>
    </table>
    </center>
    </form>
    </body>
    </html>

    this Corrected code works perfectly
    <html>
    <head> <title>Create MultipleChoice Questions</title> </head>
    <script language="JavaScript">
    function valid(form) {
    if(form.file.value == ""){
    alert("Please enter the file name");
    frmValid.file.focus();     
    }else{
         frmValid.action="writeXML.jsp";
         frmValid.submit();
    </script>
    <body bgcolor="#cccccc">
    <% int count = 0;
    int qNumber=-1;
    String number = clearNull(request.getParameter("nOfq"));
    if(! number.equals(""))
    qNumber = Integer.parseInt(number);
    %>
    <form name="frmValid" method="POST" >
    <center>
    <table bgcolor="silver" border="1" width="75%">
    <tr align="center"><td><b>Type in the Name of your Questionnaire here eg. BlackHistory. Dont leave any spaces between letters</b><br>
    <textarea name="file" rows="1" cols="25"></textarea><br>
    </td></tr>
    <% for(int i=1;i<qNumber+1; i++) { %>
    <%count++;%>
    <tr align="center" bgcolor="#336699"><td><b>QUESTION <%= count %>: </b><br>
    </td></tr>
    <tr align="center"><td><b>ENTER QUESTION:</b><br>
    <textarea name=<%="questionText"+i%> rows="5" cols="65"></textarea><br>
    </td></tr>
    <tr align="center"><td><b>CHOICE 1:</b><br>
    <textarea name=<%="choice_1"+i%> rows="2" cols="50"></textarea><br>
    </td></tr>
    <tr align="center"><td><b>CHOICE 2:</b><br>
    <textarea name=<%="choice_2"+i%> rows="2" cols="50"></textarea><br>
    </td></tr>
    <tr align="center"><td><b>CHOICE 3:</b><br>
    <textarea name=<%="choice_3"+i%> rows="2" cols="50"></textarea><br>
    </td></tr>
    <tr align="center"><td><b>CHOICE 4:</b><br>
    <textarea name=<%="choice_4"+i%> rows="2" cols="50"></textarea><br><br><br>
    </td></tr>
    <tr align="center" bgcolor="#679995"><td><b>CORRECT ANSWER:</b><br>
    <textarea name=<%="cAnswer"+i%> rows="2" cols="50"></textarea><br><br><br>
    </td></tr>
    <% } %>
    <tr>
    <td align="center"><input type="submit" name="next" value="NEXTT" onClick="valid(this.form)">
    <td align="center"><input type="hidden" name="qCount" value="<%=count+1%>">
    </td></tr>
    </table>
    </center>
    </form>
    </body>
    </html>
    <%!
    private String clearNull( String sField ) {
    return ( sField == null ) ? "" : sField;
    %>

  • Can't get Struts validator to work with ADF 10.1.3.36.73 in Jdev 10.1.3.0.4

    I am attempting to use the "How to Use the Struts Validator Plug-in with JDeveloper 10g" written by Duncan in a JDeveloper 10.1.3.0.4 application with standard model/ViewController projects. I am using JSP/Struts/ADF technologies.
    I have performed the below:
    Struts Config:
    <form-bean name="surveyDataForm" type="oracle.adf.controller.v2.struts.forms.BindingContainerValidationForm" className="oracle.adf.controller.struts.forms.BindingContainerValidationFormConfig"/>
    <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
    <set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
    </plug-in>
    In the validation.xml:
    <!DOCTYPE form-validation
    PUBLIC "-//Apache Software Foundation//
    DTD Commons Validator Rules
    Configuration 1.0//EN"
    "http://jakarta.apache.org/
    commons/dtds/validator_1_0.dtd">
    <form-validations>
    <formset>
    <form name="surveyDataForm">
    <field property="EmpName" depends="required">
    <arg0 key="survey.name"/>
    </field>
    <field property="DateOfService" depends="required">
    <arg0 key="survey.service.date"/>
    </field>
    <field property="ReloContractor" depends="required">
    <arg0 key="survey.relo.contract"/>
    </field>
    </form>
    </formset>
    </form-validations>
    And in my JSP, I have:
    <script type="text/javascript">
    <html:javascript formName="surveyDataForm"/>
    </script>
    <html:form action="/survey.do" onsubmit="return validateSurveyDataForm(this)">
    (The validation-rules.xml was copied from the JDev install jakarta-struts folder).
    I can now see the Javascript showing up in my JSP page, but I don't have a method generated for validateSurveyDataForm or any form like this. I didn't think I had to create this. Also, even without the Javascript, the validator is not called because the JBO errors for required are still showing up. The only thing I have not done is included the modelReference in the Form Bean definition in the struts-config.xml. I'm not sure this will work, or even what to populate this with, as the UIModel.xml is replaced by PageDef.xml and DataBindings.cpx changes.
    Anyone have any ideas?
    Shay

    Only have one network; wireless. On it's own, the MacBook can use wifi to surf the net and Apple TV can watch movie previews from Apple via wifi.
    It did work about two months ago. I haven't used it since then for home sharing but have used the Apple TV on its own.
    I read the Troubleshooting page on Apple Support. It involves turning various things on and off, which I did

  • How to know if a file browser item is not null using javascript fucntion

    Hi
    <br><br>
    I tried to use javascript for validation. I have a file browser item named P55_FILE_NAME and I would like to know if this item is null or not before submit.
    <br>
    I wrote this function :<br><br>
    function validate_import(f_n){<br>
         if (trim(document.getElementByName(f_n).src) == "")<br>
         {<br>
         alert ("File name is empty.");<br>
         document.getElementByName(f_n).focus();<br>
         }<br>
         else{<br>
         doSubmit('SUBMIT');<br>
         }<br>
    } <br><br>
    When I press submit button I got an error, sounds like the src method does not exist in my input item. <br>
    Then, I looked my source page an I found this :<br><br>
    input type="file" name="p_t01" size="30"
    <br><br>
    there is know src method and the name is not P55_FILE_NAME and I don't want to use <b>p_t01</b> that will change.<br>
    <br>
    I need your help.<br>
    Benn

    Hello,
    The p_txx notation is the internal name the ApEx engine attaches to each page item. It starts with p_t01 (for the first item on page) and can end with p_t99 (hence, the max 99 items per page limit). You can see these names in your HTML source code.
    The bug in the File Browse item (fixed in version 2.2) is that the ID of the item is the internal name instead of the item name. Hence, in order to use DOM, you need to use this internal notation.
    If the File Browse item id is p_t01, you can null its content by using something like that (V2.0 notation) :
    html_GetElement('p_t01').value = '';I'm using the same, and similar code, for manipulating this type of item with no problems.
    Please document the use of this workaround, as when you'll upgrade your ApEx system, you will have to change this code back to the standard – item id equal item name.
    (Please follow Scott's advise, and keep your logic connected issues on the same thread. It will get you more quick and accurate help).
    Regards,
    Arie.

  • How to do fronwend validations with out JAVA code

    Hi Frndz...
    In my application i did the fron end validatios as per requirment in java , as per requirement my application requires too much validations i did entirely in java .
    But itz takling much time , in java will go for javascript for validations is there any thing is aivla in webdyn pro for vaildations
    my code
    if(division1 !=null && division1 !="")
           blnValueDivision = true;                         }
    else
         msgMgr.reportContextAttributeMessage(wdContext.nodeInitTableV().getInitTableVElementAt(i),attrInfoDivision,IMessageNoBusinessSheetComp.ERROR__MESSAGE__MANDATORY,new Object[]{"Division"},true);
         blnValueDivision = false;
         if(location1 !=null && location1 !="")
         blnValueLocation = true;
         else
         blnValueLocation = false;

    Hi,
    webdynpro doesnt support java script handling . This is taken care by the framework. Only option is to reduce the roundtrip and try to validate every thing in a submit button.
    Regards
    Ayyapparaj

Maybe you are looking for