I have created a django application. Using this app users can be created or deleted. But while creating a user, when we leave 1 of the field (Employee ID Field) null its not getting submitted and its throwing this error - invalid literal for int() with base 10: '' . So i guess validating that field alone and submitting that form, only if employee ID Field is non null can solve my problem. So for doing that i created a javascript and wants that js function to be called before submitting. Need to submit that form only if that field is non-empty. The alert box is coming saying to Enter the employee ID, but once i click ok to alert box, the same error comes again.Can somebody help me to solve this. I am quite new to Django and programming. I will paste my code here.
Add New User to Employee List
</h4><br><br><br>
<form name="myForm" action="http://10.1.0.90:8080/createEmployee/" method="POST">
<br>Name: <input type="text" name="userName" style="color: black; background-color: #BDBDBD" /><br /><br>
Designation:
<select name="designation" style="color: black; background-color: #BDBDBD" >
<option value="Trainee" >Trainee</option>
<option value="Software Engineer Trainee">Software Engineer Trainee</option>
<option value="Software Engineer">Software Engineer</option>
<option value="Senior Software Engineer">Senior Software Engineer</option>
<option value="Project Manager">Project Manager</option>
<option value="System Administrator">System Administrator</option>
<option value="Tester">Tester</option>
</select><br>
<br>
EmployeeID:<input id ="empid" type="text" name="employeeID" style="color: black; background-color: #BDBDBD" /><br><br>
Contact Number: <input type="text" name="contactNumber" style="color: black; background-color: #BDBDBD" /><br><br>
Project: <input type="text" name="project" style="color: black; background-color: #BDBDBD" /><br><br>
Location: <input type="text" name="location" style="color: black; background-color: #BDBDBD" /><br><br>
E-mail: <input type="text" name="email" style="color: black; background-color: #BDBDBD" /><br><br>
Skills: <input type="text" name="skills" style="color: black; background-color: #BDBDBD" /><br><br>
Date Of Join: <input type="text" id="datepicker" name="dateOfJoin" style="color: black; background-color: #BDBDBD" /><br><br>
<br><br>
<input type="submit" value=" Submit " onclick="isEmpty()" /><br />
</form>
<script type="text/javascript">
function isEmpty(){
if ((document.myForm.EmployeeID.value.length==0))
{
alert("Please Enter Employee ID");
return true;
}
else
{
return false;
}
}
nbsps.