Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

form validation

  • 02-12-2008 2:46pm
    #1
    Closed Accounts Posts: 184 ✭✭


    Anyone know of an easy to validate a form using javascript?


Comments

  • Registered Users, Registered Users 2 Posts: 180 ✭✭marcphisto




  • Closed Accounts Posts: 184 ✭✭vodkadub


    Im looking for something hand coded, thanks anyway


  • Registered Users, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


    There really isn't a way to use javascript for form validation unless is server side javascript.


  • Registered Users, Registered Users 2 Posts: 21,263 ✭✭✭✭Eoin


    As Evil Phil says, server side is the place to do it. Doing it client side should only be for the purposes of usability, and not relied on by the site.

    That said, here's a quick example you can work from:
    [html]
    <script type="text/JavaScript">
    function checkForm()
    {
    if (document.getElementById("txtName").value == "")
    {
    alert("Please enter your name");
    return false;
    }
    return true;
    }
    </script>
    <form name="frmTest" action="this.asp" method="post" onsubmit="return checkForm()">
    Name: <input type="text" name="txtName" id="txtName" value="" />
    <input type="submit">
    </form>
    [/html]


Advertisement