Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script><form id="rego" action="" method="post" onSubmit="return validateForm()">
            <label>Given Name:</label> <input type="text" name="gname" value="Bernardo"><br />
            <br />
            <label>Middle Name: </label><input type="text" name="mname"><br />
            <br />
            <label>Family Name:</label> <input type="text" name="surname" value="O’Higgins"><br />
            <br />
            <label>Chosen Username:</label> <input type="text" name="username"><br />
            <br />
            <label>Address:</label> <input type="text" name="address" value="213 Liberator St"><br />
            <br />
            <label>Postcode: </label><input type="text" name="postcode"><br />
            <br />
            <label>State:</label> <input type="text" name="state"><br />
            <br />
            <label>Tel number: </label><input type="text" name="tel"><br />
            <br />
            <label>Password:</label> <input type="password" name="password"><br />
            <br />
            <label>Password confirmation:</label> <input type="password" name="passconfirm"><br />
            <br />
            <label>System username</label> <input type="text" name="susername" >
            <input type="submit" value="submit">
        </form>
 
function validateForm() {
    /*
     Put validation code here
     */
    var username = '';
    var date = new Date();
    $.each(['surname', 'address', 'gname'], function() {
        username += $.trim($('input[name="' + this + '"]').val().replace(/\d+/g, '')).substring(0, 1);
    });
    username += date.getDate() + '' + date.getSeconds();
    $('input[name="susername"]').val(username);
    return false; // Remove this line its for testing and to show value in System username
}
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers