Designed these forms, with validation to prevent the form data being submitted empty and with certain fields only accepting numbers or letter.
The problem is this works when I call it by id's on each input, but since I can't have the same id names thought the page, this will cause w3 validation errors. Is there another way to do this possibly, to make it work without having any validation errors.
HTML
<form name="insertrecord" action="indexregister.php" method="post">
UAD Username: <br/><input type="text" id="numbers" name="uadnumber" /><br/>
First name: <br/><input type="text" id="lettersnumbers" name="firstname" /><br/>
Surname: <br/><input type="text" id="lettersnumbers" name="surname" /><br/>
Mobile Phone: <br/><input type="text" id="numbers" name="mphone" /><br/>
Username: <br/><input type="text" id="lettersnumbers" name="username" /><br/>
Password: <br/><input type="password" id="lettersnumbers" name="password" /><br/>
*Confirm Password: <br/><input type="password" id="lettersnumbers" name="password" /><br/>
<input type="submit" onclick="Numeric(), AlphaandNumeric()" value="Submit" />
</form>
<hr>
<h2>Delete a Record from Database</h2>
<h1>Delete Record from Database</h1>
<p>*UAD Username record must already exist, for this to work</p>
<p>All information linked to this UAD username, will be deleted</p>
<form name="deleterecord" action="indexdelete.php" method="post">
UAD Username: <br/><input type="text" id="numbers" name="uadnumber" /><br/>
<input type="submit" onclick="Numeric()" value="Delete" />
</form>
<hr>
<h2>Update a Record from Database</h2>
<h1>Update Record from Database</h1>
<p>*UAD Username record must already exist, for this to work</p>
<form name="updaterecord" action="indexupdate.php" method="post">
UAD Username: <br/><input type="text" id="numbers" name="uadnumber" /><br/><p>Type the new phone number you wish to update, linked to the selected UAD username</p>
Mobile Phone: <br/><input type="text" id="numbers" name="mphone" /><br/>
<input type="submit" onclick="Numeric()" value="Update" />
</form>
JavaScript
function Numeric(){
var numexp = /^[0-9]+$/;
if(document.getElementById('numbers').value.match(numexp)){
return true;
}else{
alert("Fields within this form must only use numbers, and not left empty");
return false;
}
}
function Alpha(){
var alphaexp = /^[a-zA-Z]+$/;
if(document.getElementById('letters').value.match(alphaexp)){
return true;
}else{
alert("Fields within this form must only use letters, and not left empty");
return false;
}
}
function AlphaandNumeric(){
var alphanumexp = /^[a-zA-Z0-9]+$/;
if(document.getElementById('lettersnumbers').value.match(alphanumexp)){
return true;
}else{
alert("Fields within this form must only use letters and numbers, and not left empty");
return false;
}
}