fix: validate url starts with http or https for job form

This commit is contained in:
Jannat Patel
2025-12-10 14:06:17 +05:30
parent 73ee1b2f09
commit 7fc066679d
4 changed files with 14 additions and 4 deletions

View File

@@ -254,8 +254,18 @@ onMounted(() => {
}
if (props.jobName != 'new') jobDetail.reload()
addKeyboardShortcuts()
})
const addKeyboardShortcuts = () => {
document.addEventListener('keydown', (e) => {
if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === 's') {
e.preventDefault()
saveJob()
}
})
}
const saveJob = () => {
validateJobFields()
if (jobDetail.data) {
@@ -359,7 +369,7 @@ const breadcrumbs = computed(() => {
usePageMeta(() => {
return {
title: props.jobName == 'new' ? 'New Job' : jobDetail.data?.title,
title: props.jobName == 'new' ? 'New Job' : jobDetail.data?.job_title,
icon: brand.favicon,
}
})

View File

@@ -16,7 +16,7 @@ class JobOpportunity(Document):
self.company_logo = validate_image(self.company_logo)
def validate_urls(self):
validate_url(self.company_website, True)
validate_url(self.company_website, True, ["http://", "https://"])
def autoname(self):
if not self.name:

View File

@@ -28,7 +28,7 @@ class LMSAssignmentSubmission(Document):
)
def validate_url(self):
if self.type == "URL" and not validate_url(self.answer):
if self.type == "URL" and not validate_url(self.answer, True, ["http://", "https://"]):
frappe.throw(_("Please enter a valid URL."))
def validate_status(self):

View File

@@ -49,7 +49,7 @@ class LMSSettings(Document):
def validate_contact_us_details(self):
if self.contact_us_email and not validate_email_address(self.contact_us_email):
frappe.throw(_("Please enter a valid Contact Us Email."))
if self.contact_us_url and not validate_url(self.contact_us_url, True):
if self.contact_us_url and not validate_url(self.contact_us_url, True, ["http://", "https://"]):
frappe.throw(_("Please enter a valid Contact Us URL."))